how to apply for loop for different vectors
Ältere Kommentare anzeigen
I have two vectors or more depending upon the user, and I want to run the program many times depending upon this number of vectors. Then, for each run, I need to check the length of each vector and apply its related formulas depending upon the its length. I wrote the following program but it does not work, it takes only the second vector!!
M=[1 2 3 4];
M=[6 7 7 8 2 1 3 2];
k=length(M)
number_of_vectors=2;
for i=1:number_of_vectors
if k==4
h=M-1
elseif k~=4
h=M-3
end
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!