Can I get outputs numbered each time it goes through a loop?
이전 댓글 표시
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?
채택된 답변
추가 답변 (1개)
Mischa Kim
2014년 2월 17일
편집: Mischa Kim
2014년 2월 17일
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.
카테고리
도움말 센터 및 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!