Can I get outputs numbered each time it goes through a loop?
Show older comments
I have a "for" loop that runs through my data and gives outputs nicely. It looks like....
a=[334.480, 334.481, 334.486, 334.485, 334.480, 334.480, 334.478, 334.479, 334.479, 334.483];
b=[341.013, 341.017, 341.017, 341.017, 341.017, 341.025, 341.020, 341.021, 341.026, 341.025];
>> for k=1:10-5+1
c=a(k:k+5)
d=b(k:k+5)
m1=mean(a)
m2=mean(b)
co=corrcoef(a,b)
va=varr(a,b)
end
As it runs the outputs are labeled c, d, m1, m2, co, and va each time. Is there a way to have matlab tell me this is the 3rd time this has been output? Do I have to ask matlab after it has run, or can I use code to have matlab tell me before I ask?
Accepted Answer
More Answers (1)
Mischa Kim
on 17 Feb 2014
Edited: Mischa Kim
on 17 Feb 2014
Ry, you could add
disp(['Loop iteration: ', num2str(k)]);
just before the end of the loop. It displays some text and the loop index k.
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!