How to plot different iterations with a time delay in for loop?
조회 수: 23 (최근 30일)
이전 댓글 표시
Hi,
I am having some trouble plotting different iterations with a time delay of for example one second in my loop:
load Data_SATP.mat
Days_SATP = Data_SATP([1:101:3131],[2]);
L_ATP = Data_SATP([2:101],[1]);
for j = 1:31
Sw = Data_SATP([(2+(101*(j-1))):(101*j)],[2]);
mat(j,:)=Sw
end
figure(2)
for k=(1:31);
plot(L_ATP,mat((1:31),:))
end
after which I fix the labels and axis. Now I get one plot of 31 graphs, but I would like to make the graphs appear one after each other in the same plot, preferably as an animated plot, but otherwise at least in the order of graph1, 1 second later graph2, etc.. I tried with pause(1), and I got it working once but after that I couldn't get it to work again after I changed some things, so advice on that is also welcome.
Thanks
[EDITED, Jan, Code formatted]
댓글 수: 0
답변 (1개)
Jan
2015년 11월 29일
The body of the FOR loop over k does not depend ob k at all. I guess, that you want mat(k, :):
H = plot(L_ATP,mat(1, :))
for k = 2:31
pause(0.5);
set(H, 'YData', mat(k, :));
end
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!