Answered
Using C libraries (FFT) in a s-function simulink
Two options come to mind, either use a <http://www.mathworks.se/help/matlab/creating-c-c-and-fortran-programs-to-be-callable-fro...

13 years ago | 0

Answered
How do I count the numbers of 0s and display the results?
your_val = sum(your_mat(:)==0);

13 years ago | 0

| accepted

Answered
Variables not saved after function completes. Help needed
Have the function return the variables you want to keep, otherwise they are destroyed upon exit. function [a,b,c] = checkfi...

13 years ago | 2

Answered
Clearing Global variables... except for.
<http://www.mathworks.com/matlabcentral/fileexchange/7129 keep4>

13 years ago | 0

Answered
How to print to pdf a square of a exact dimension 20 microns?
A micron is 10e-6 metres. That is one thousandth of a millimetre. Let's say you print at 1200 dpi, That's around 470 dots per ce...

13 years ago | 1

Answered
how can I increase accuracy
doc vpa That would work, if you have the symbolic math toolbox.

13 years ago | 0

Answered
How to remove the lines from a stairstep graph
x = 1:10; y = x; addX = arrayfun(@(x) [x NaN x],x(2:end),'uniformOutput',false); x = [x(1) cell2mat(addX)]; ad...

13 years ago | 0

Answered
Data manipulation of a financial time series
Here is what you can do, assuming your_data is a cell matrix containing strings. your_data{1} = '01/08/2007'; your_data{...

13 years ago | 0

Answered
how to read data from desired lines of a large data set?
That is one big chunk of data. I have several suggestions: * Preallocate: in your code your are growing _datas_ at each itera...

13 years ago | 0

Answered
Long file name read
Assuming the files are in the current directory: your_files = dir('2012*.txt'); But otherwise you could always give the ...

13 years ago | 0

Answered
How can I vectorize my code and use fsolve to solve thousands of non-linear equations simulataneously?
What does a long time mean? You realize you are trying to solve almost 400 million systems of non-linear equations. That is boun...

13 years ago | 0

Answered
\n Not Generating New Line In fprintf fid Command When Writing To .dat File
I assume you are in Windows. The return of carriage for Windows is *"\r\n"*. Try changing that. Otherwise, use wordpad instead o...

13 years ago | 0

| accepted

Answered
how is working for loop?
doc for Matlab's documentation is, in my opinion, quite decent. It is always a good place to start.

13 years ago | 1

| accepted

Answered
Why does num2str of a single output up to 17 digits?
If you try: a=single(1.122658646554312321654643513232464651); num2str(a,20); This will produce 1.12265861034393310...

13 years ago | 0

Answered
Decimals to Roman Numerals
a = 1000; a = num2str(a); a = a - '0'; _a_ is a row vector, where each element is one of your x's

13 years ago | 0

| accepted

Answered
How can you include indices in a function of a discrete process?
j=1:10; j is a row vector. s = 2.*r(j)+j; You are trying to add a scalar to a row vector. No can do. You can however...

13 years ago | 0

Answered
How do we change the size of a figure (graph) to be larger than the default?
scrsz = get(0,'ScreenSize'); figure('Position',scrsz); plot(rand(10,1));

13 years ago | 0

| accepted

Answered
processing multiple data in matlab at once
You could try using a cell array instead: your_data = cell(numFiles,1); Populate it (ideally when you read them) your...

13 years ago | 1

Answered
check if a file exists
doc exist

13 years ago | 2

Answered
Question about arrays to elements.
a = 0:20; a = num2str(a); a = [a(:)']; a(regexp(a,'[^0-9]')) = [];

13 years ago | 0

Answered
How to plot a matrix?
Given your figure it looks like you have a two-column matrix. The bottom left plot one is given by: plot(your_data(:,1),you...

13 years ago | 6

| accepted

Answered
preallocate vector or not
You should preallocate for speed, just try: numVals = 10^5; noAlloc = []; Alloc = NaN * ones(numVals,1); tic ...

13 years ago | 1

Answered
How to inspect local variables of a function
Use breakpoints either in your script and/or in your function.

13 years ago | 3

| accepted

Answered
how to read n first lines of a txt file and keep the format when writing the read data to the new (another) text file
To read into a cell array, line by line: fid = fopen(your_filename,'r'); numLines = 4; your_text = cell(numLines,1); f...

13 years ago | 3

| accepted

Answered
How do I combine two different distributions in MATLAB?
your_fun = @(average,var,k,numRows,numCols) average + var.*randn(numRows,numCols) + exprnd(k,numRows,numCols) And to get va...

13 years ago | 0

| accepted

Answered
How can I solve this error can someone help
It means that you do not have the required toolboox in that computer. Either test your code in a computer with the optimization...

13 years ago | 0

Answered
Share your favorite snippet or utility
<http://www.mathworks.com/matlabcentral/fileexchange/181 keep> Not really a snippet, but useful.

13 years ago | 4

Answered
Questions about Fractions and integers?
If integer, the following will return true: floor(your_num) == your_num; Otherwise, if the number has a fractional part,...

13 years ago | 0

Answered
Direction of Arrows in Quiver (2D)
I'm gonna venture a wild guess. We don't know what your data looks like (well, except from the plot). However, this line: m...

13 years ago | 0

| accepted

Load more