nested for loop help

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

 采纳的回答

Jan
Jan 2011-8-10
Use c as index...
Results(:, c) = Check(:, 1);

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by