nested for loop help

1 view (last 30 days)
Jeremy Burke
Jeremy Burke on 10 Aug 2011
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

Accepted Answer

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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!