How to plot different iterations with a time delay in for loop?
27 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Jan
on 29 Nov 2015
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
See Also
Categories
Find more on Annotations 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!