Answered
Why my prompt (inputdlg) doesn´t work right?
After <https://www.mathworks.com/help/matlab/ref/str2double.html |str2double|> the variable |answer| is a double, not a cell arr...

9 years ago | 0

| accepted

Answered
how to sort a combination of numbers and strings
Download and use my FEX submission <https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort |nats...

9 years ago | 1

| accepted

Answered
Piecewise function for structural analysis
MATLAB is most efficient when working with complete arrays at once, so you can simply use logical indexing and create the piece-...

9 years ago | 0

Answered
I want to divide each row of a matrix with corresponding element in another matrix .Please help.
Use <https://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|>: >> A = [9,6,3;4,2,8;1,0,0]; >> B = [3,2,1]; >> ...

9 years ago | 2

| accepted

Answered
How to delete specific rows in a matrix
You need to use <https://www.mathworks.com/help/matlab/ref/all.html |all|> or <https://www.mathworks.com/help/matlab/ref/any.htm...

9 years ago | 0

| accepted

Answered
I have a porblem with reading a raspberry pi file in a fuction. I get the Erro: Call to MATLAB function aborted: Invalid file identifier. Use fopen to generate a valid file identifier.
The best solution is to always return |fopen|'s second output message, and use it to display exactly what occurred when |fopen| ...

9 years ago | 0

Answered
Very little measure,can't print them
Change the <https://www.mathworks.com/help/matlab/ref/format.html |format|> to suit your needs: >> format('shortG') >> X...

9 years ago | 0

| accepted

Answered
Sum in Loop in Array
Use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> [accumarray(ccy(:),weight(1,:).'),accumarr...

9 years ago | 0

Answered
How to sort a structure array?
"i tried using natsortfiles..but of no use" I am surprised that my FEX submission was no use to you, considering that it was wr...

9 years ago | 0

Answered
Comparing updated array from two consecutive iterations
Like this: prv = 0; % pick first previous value for ... new = ... ...compare prv & new, do whatever p...

9 years ago | 2

| accepted

Answered
How to remove an specific array from matrix
>> A = [1,2,0,0,0;2,100,5,100,1;36,12,25,100,0;8,5,100,0,0;9,1,2,5,9;1,2,3,89,100]; >> L = A; >> L(L==100) = 0; >> L ...

9 years ago | 0

Answered
Multiple solutions with specific range input
Actually there are more solutions: >> fun = @(x)abs(abs(abs(x)-5)-2); >> foo = @(x)fun(x)-1; >> x = -5:0.1:7; >> i...

9 years ago | 0

Answered
Loading a mat file gives me a array of 41 doubles...
@Quentin Stas de Richelle: it is highly recommended to always |load| into a variable, to avoid exactly this kind of "where does ...

9 years ago | 1

Answered
How can I use matlab to draw color blocks
Here is one way. Note that I used my FEX submission <https://www.mathworks.com/matlabcentral/fileexchange/48155-convert-between-...

9 years ago | 0

| accepted

Answered
Return values from nested if statement in function
Using loops is a very inefficient way to perform this task: MATLAB is most efficient when operating on complete arrays, for exam...

9 years ago | 1

| accepted

Answered
Selecting a range of rows at a time
*Method one: use a loop and basic indexing:* this is the easiest and most efficient solution: out = NaN(40,50); for k = ...

9 years ago | 2

| accepted

Answered
How to fix : invalid first data argument
All of the variables |v01|, etc are strings (which is clear because that is what you are requesting from the edit boxes). But on...

9 years ago | 2

| accepted

Answered
split comma-separated rows into separate columns
>> Z = cellfun(@(c)cellfun(@(v)v(:),c,'uni',0),x,'uni',0) Z = {1x1 cell} >> Z{1}{1} ans = 2 1...

9 years ago | 0

| accepted

Answered
convert cell array to 3d array
Assuming that all numeric arrays are of a size that can be concatenated together: >> cell2mat(cellfun(@cell2mat,a,'uni',0)) ...

9 years ago | 0

| accepted

Answered
Split array into separate arrays at row with NaNs
First lets define some trial data: >> M = [0,1;2,3;NaN,NaN;4,5;6,7;NaN,NaN;8,9] M = 0 1 2 3 NaN ...

9 years ago | 4

| accepted

Answered
How do I run a command only if certain characters exist in a string
Where |fnm| is the filename: C = regexp(fnm,'M[a-z]+','once','match'); switch C{1} case 'Min' ... ...

9 years ago | 0

| accepted

Answered
Unable to get a plot in a Graph
*Method One: |ezplot|:* >> a=3.0; d=14; G=6.0; E=60; >> f = @(Le) pi*a*d*Le+sqrt((pi^2*G*E*d^3)/2); >> ezplot(f, [0.0...

9 years ago | 1

| accepted

Answered
How to vertically concatenate matrices inside a matrix?
You seem to have nested cell arrays, so perhaps this might work: cellfun(@(a,b)cellfun(@vertcat,a,b,'uni',0),A,B,'uni',0)

9 years ago | 0

| accepted

Answered
Warning: Colon operands cannot be logical
If |im| is logical (which it could be if it is a binary image), then line ten contains this: min(im(:)):1:max(im(:)) wher...

9 years ago | 1

| accepted

Answered
Set specific values to NaN
>> A = [1,2,5,2;2,4,4,1;3,3,4,3;4,5,4,3;5,4,3,3;6,6,7,3;6,7,8,3;6,7,8,3;6,7,8,5]; >> idx = cumprod(double(diff(flipud(A))==...

9 years ago | 1

| accepted

Answered
How can i create matrix automatically?
>> fun = @(n)ceil((1:n)/2); >> fun(3) ans = 1 1 2 >> fun(4) ans = 1 1 2 2 >> fun(7) an...

9 years ago | 1

| accepted

Answered
How to create a row vector from rows with different length in a loop?
<https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html Comma separated lists> are your friend. Learn to u...

9 years ago | 0

| accepted

Answered
Finding columns by name in a cell array
idx = strncmp(QC(1,:),'A_',2); idx = idx | [idx(2:end),false]; Q = QC(:,idx);

9 years ago | 0

| accepted

Answered
Attempted to access best_dim(1); index out of bounds because numel(best_dim)=0.
best_dim = find(T_MIN(1,:) == min(T_MIN(1,:))); dim = best_dim(1); |best_dim| is empty, therefore there is no element 1....

9 years ago | 0

| accepted

Load more