Hello,
I am trying to use a nested for loop which calls a separate function within the loop. The goal is to generate a new matrix which is essentially 25 "trials" of the inner function. What is happening when I run the code is that the first column of the Results matrix is correct, while each subsequent column remains all zeros. Can anyone spot my mistake? Any help is greatly appreciated!
Here's my code:
Results = zeros(size(C,1),25);
for c = 1:25
for r = 1:size(C,1);
[MF,YF,Mult,Check] = YieldForce(C,T);
Results(:,1)=Check(:,1);
end
end
Jeremy

 Akzeptierte Antwort

Jan
Jan am 10 Aug. 2011

0 Stimmen

Use c as index...
Results(:, c) = Check(:, 1);

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!

Translated by