Answered
How to sort the files in a folder by date?
S = dir(...); S = S(~[S.isdir]); [~,idx] = sort([S.datenum]); S = S(idx)

8 years ago | 9

| accepted

Answered
How to sort out the matrix based on 1st column?
"How to sort out the matrix based on 1st column?" The sortrows function is stable, in the sense that the order of any two rows ...

8 years ago | 2

| accepted

Answered
Converting glcm 8*8 matrix to single row vector
Depending on the order you want, probably one of these: reshape(glcm,1,[]) reshape(glcm.',1,[])

8 years ago | 1

| accepted

Answered
How can i correct the below Matlab code
S0 = [0.1,0.2,0.3,0.4,0.5]; D0 = [2.1,2.2,2.3,2.4,2.5]; for k = 1:numel(S0) Sr = S0(k); Du = D0(k); ... the res...

8 years ago | 0

| accepted

Answered
how to creat this vector?
Exactly like in my answer to your earlier question: https://www.mathworks.com/matlabcentral/answers/442047-how-to-creat-this-ve...

8 years ago | 1

Answered
Help sending values through varargin?
The simplest solution is that whenever you call your function handle, add this at the end: fun(...,varargin{:}) For example: ...

8 years ago | 1

| accepted

Answered
Editing a cell array.
To get the actual numeric values taking into account the SI prefixes you can use my FEX submission sip2num, which can be downloa...

8 years ago | 0

Answered
Faster way of replacing multiple rows with same vector without using a loop?
Here are your two main choices for avoiding a loop. Method one: match the elements. You need to make the LHS and the RHS have t...

8 years ago | 0

| accepted

Answered
Optimization running. Error running optimization. Not enough input arguments.
According to the ga help the function should accept one input argument and return a scalar: "Write the objective function to acc...

8 years ago | 2

| accepted

Answered
how to creat this vector?
An easy solution using a loop: >> X = [1,0,0,1,1,0,1,1,1,1,0,0,0,1,1,0,1,1,1,1,1,0] X = 1 0 0 1 1 0 1 1 1 ...

8 years ago | 1

| accepted

Answered
read cell array and split into one cell array of multiple rows
name = {... 'ABCDEFGHIJKLMNOPB C D E F G ...

8 years ago | 2

| accepted

Answered
imshow command will not display my images
The reason is very simple: you forgot to use the path when you tried to read the file: D = 'C:\Users\User\Documents\MATLAB\stim...

8 years ago | 0

Answered
Undefined operator '*' for input arguments of type 'cell'
matrix.metcoef{i} = matrix.metcoef{i} .* -1 matrix.metcoef{i} = -matrix.metcoef{i}; % SIMPLER % ^ ^ ...

8 years ago | 0

| accepted

Answered
loop structure variables in formula
Rather than using loops you should learn how to use neat comma-separated lists: https://www.mathworks.com/help/matlab/matlab_pr...

8 years ago | 0

| accepted

Answered
Beginner MATLAB question (I just started using matlab a week ago)
Simpler and more efficient to use logical indexing: idx = ss(:,1)==1; out = ss(idx,2) If you really want to use |find|: idy ...

8 years ago | 0

| accepted

Answered
How do i use a pair of nested for loops to store a series of 9 related numbers in a 3x3 matrix?
A = str2double(input('start:','s')); S = str2double(input('step:','s')); X = nan(3,3); for R = 1:3 for C = 1:3 ...

8 years ago | 0

| accepted

Answered
Assigning count values to the column of a matrix
Either one of these, depending on the order that you want: A(:,3) = 1:29 A(:,3) = 29:-1:1

8 years ago | 1

| accepted

Answered
5 outputs of a function, store each output data in 5 arrays from for loops
% parameters: B = 14; L = 14; r = 9; R = 6; % bad idea to use variable names that differ only by case Ach = 231; A...

8 years ago | 0

| accepted

Answered
How to create a colormap attributing specific colour to each element?
A = [1,2,3,4;2,2,3,1;1,1,4,2]; map = [0,0,1;0,0,0;0,1,0;1,1,0]; % [blue;black;green;yellow] imagesc(A,[1,4]) % better to set t...

8 years ago | 0

Answered
Removing a row from a matrix based on certain conditions
You do not explain how you want to handle the 8 columns in your logical comparisons: do you only want to remove the entire row i...

8 years ago | 0

| accepted

Answered
how can I choose random "n" matrices from array of matrices ?
If you followed the advice I gave in response to your last question: https://www.mathworks.com/matlabcentral/answers/441492-how...

8 years ago | 0

Answered
How to remove an entry within a cell of a cell array
cellfun(@(x) x(x>2), C, 'Uni', 0)

8 years ago | 0

| accepted

Answered
for loops and creating new vectors
You don't need any loops, just use ismember: >> mytable = [111,11,1;222,22,2;444,44,4;666,66,6;999,99,9] mytable = 111 ...

8 years ago | 0

| accepted

Answered
Split character arrays at given column
"I want to be able to store all the numbers in a vector ..." That is easy with sscanf: >> vec = sscanf(val.','%f') vec = ...

8 years ago | 0

| accepted

Answered
For loop cycle struct
This is MATLAB, so it is simpler to avoid using a loop: >> S(1).Mass = 200; S(1).Dist=50; >> S(2).Mass = 350; S(2).Dist=100; ...

8 years ago | 0

Answered
how to get the first position in the array and get size array contains matrices
Use a cell array: >> C = {m1,m2,m3,m4}; >> C{1} ans = 0 1 0 0 https://www.mathworks.com/help/matlab/cell-arrays....

8 years ago | 0

Answered
Row Sorting of Matrices
>> A = [0,2,4;0,1,6;0,0,5] A = 0 2 4 0 1 6 0 0 5 >> [~,idx] = sortrows([sum(A==0,2),A]); >> B = A(idx...

8 years ago | 1

| accepted

Answered
Why does this not vectorize
You are overwriting x values with the loop, so when you then try the vectorized code you have different x values. Clearly differ...

8 years ago | 0

Answered
How to save cells of multi-indexed array as cells in another array?
{sweeps.beams}.' Read more: https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://www.mathwork...

8 years ago | 0

| accepted

Answered
Renaming cells inside structure from variable in for loop
You can certainly rename fields dynamically: https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variab...

8 years ago | 1

Load more