Answered
calculation error or double precision limit?
You should download this and give it a try with the same examples as above: <http://www.mathworks.com/matlabcentral/fileexcha...

11 years ago | 1

Answered
Sort a matrix with respect to a date.
Probably the easiest way is to simply convert those date strings to date numbers, which can then be sorted together with the bin...

11 years ago | 1

| accepted

Answered
for loop that will iterate through the integers from 32 to 255. show the corresponding character from the character encoding
Like most MATLAB code it is easier and faster without a loop: >> char(32:255) ans = !"#$%&'()*+,-./0123456789:;<=>?@ABCD...

11 years ago | 0

Answered
i have a matrix A of 1 column and another B of 4 columns. need to do some operations of A with each column of B and to get answer as C1,C2,C3,C4 using loops . Is it possible?
The best solution would be to _not_ create numbered variables, but to simply keep all of the data together in one numeric array....

11 years ago | 0

Answered
Function syntax vs command syntax, uigetfile and load
*The problem* Your variable names |path| and |load| and |menu|. Look at these lines: menu=uimenu(fh, 'Label', 'test')...

11 years ago | 1

Answered
Help with the matrix creation pls ? if possible not a hardcoded solution but a function .
This is Roger Stafford's memory-efficient solution, proposed here <http://de.mathworks.com/matlabcentral/newsreader/view_thread/...

11 years ago | 1

| accepted

Answered
Help with the matrix creation pls ? if possible not a hardcoded solution but a function .
This code generates permutations (with replacement) of the vector |0:0.1:1|, and then selects only the rows that sum to one. I d...

11 years ago | 0

Answered
how can I save the all graphs with different names at the same time?
Make a loop that loops over each figure, and save each figure. You can generate the filenames (or other info) during each loop. ...

11 years ago | 0

Answered
How to run and pause script from ui button
Try downloading my FEX submission and running the file "cubehelix_view": <http://www.mathworks.com/matlabcentral/fileexchange...

11 years ago | 0

Answered
Block diagonal matrix on lower diagonals
New Answer! Simply define a cell vector of matrices, which must all be the same size. The rest happens automagically. Some fake ...

11 years ago | 0

| accepted

Answered
determine the limit of txt file while using regexp
It is often faster and easier just to read in all of the data from a file, then then use simple indexing to pick the bits that y...

11 years ago | 0

| accepted

Answered
Get two input from user, 2 num, and display all the perfect numbers between this two numbers.
Try this: function out = perfect(N1,N2) P = [2,3,5,7,13,17,19,31,61,89,107,127,521,607]; % Mersenne primes. C = array...

11 years ago | 0

Answered
error using == plot vectors must be the same lengths
*Problem* When I run the code (using |mR = 3| and |mT = 7| because you did not give us these values) I eventually get |fn| as...

11 years ago | 0

Answered
I've been trying to estimate this expression with while loop
There is no need to use a slow |while| loop when you can use much faster <http://www.mathworks.com/help/matlab/matlab_prog/vecto...

11 years ago | 0

Answered
For/If loop in cell array
Some fake data to try, and the loop: A{3} = 2:5; A{2} = -3:4; A{1} = -2:2; for k = 1:numel(A) idx = A{k}>=1...

11 years ago | 0

| accepted

Answered
Can anyone debug this code? Confusion with cell array
Why do you need a cell array anyway? I would suggest that you store all of those vectors together in one numeric matrix. This ha...

11 years ago | 1

| accepted

Answered
How to get the highest values on a matrix depending on the values of another matrix
In just three lines, without any loops: >> A = [1 2 1; 4 1 3; 3 8 2]; >> B = [1 2 3; 4 5 6; 7 8 9]; >> [~,~,X] = uniq...

11 years ago | 1

| accepted

Answered
3 dimension array?
Any internet search engine will give these pages at the top of the search results: <http://www.mathworks.com/help/matlab/exam...

11 years ago | 2

| accepted

Answered
Branching If , elseif and else
It helps everyone (especially yourself) when you write code using *consistent indentation*. Using consistent indentation makes c...

11 years ago | 0

Answered
How to use fprintf function?
This should get you started: >> x = [5.201,-8323.6,0.0003]; >> sprintf(' %.8f',x) ans = 5.20100000 -8323.60000000 0....

11 years ago | 2

Answered
Why I cannot run a function for each of the elements of a vector if the function calls the variable two times?
You need to use <http://www.mathworks.com/help/matlab/ref/times.html element-wise multiplication>, not <http://www.mathworks.com...

11 years ago | 0

| accepted

Answered
Wheres the best place to learn Matlab syntax?
MATLAB has one thing that very few programming languages have: *readable*, *accessible* and *helpful <http://www.mathworks.com/h...

11 years ago | 1

Answered
clear persistent variables in sub-functions
The simplest method would be to |clear| the subfunction: function temp = MyMainFunction() clear('MySubFunction') ...

11 years ago | 1

Answered
Doubt with algorithm and his results
Your code is much more complicated than it needs to be: in particular multiple nested loops are not good practice, the indexing ...

11 years ago | 0

| accepted

Answered
Evaluating a function, variable not defined
You have not defined any variable named |x|. It is like you call this: sin(x) but have not specified |x| anywhere. MAT...

11 years ago | 0

| accepted

Answered
Mean of rows and columns of several matrices in a cell
MATLAB is *fastest* and *easiest* when you stick with using numeric arrays and learn how to use the _dimensions_ of the arrays, ...

11 years ago | 1

| accepted

Answered
Conversion to cell from double is not possible.
Try putting curly braces around the value you want to assign, so that you are assigning a scalar cell array instead of a scalar ...

11 years ago | 2

Answered
Width function on arrays
MATLAB does not have width or height functions for normal arrays. You can use size to get the size of an array: d = size(X) [m...

11 years ago | 2

Answered
Using interp1 on a function that is not monotonic increasing
John D'Errico explains here why interpolation requires a monotonic independent variable: <http://www.mathworks.com/matlabcent...

11 years ago | 3

Answered
Replace 'eval' for more efficient code
https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval

11 years ago | 1

| accepted

Load more