How to set multiple pause() in a for-loop?
显示 更早的评论
I am trying to create an animation using 3 types of plot. After each of them I want to set a pause. My code looks like this:
for i= :
p1=plot1();
pause(delay1);
p2=plot2();
pause(delay2);
p3=plot3();
pause(delay3);
delete(p1);
delete(p2);
delete(p3);
drawnow
handles = guidata(hObject);
end
The problem is that the pauses get sumed and when the code ritch plot 3 is a very big delay. Can you help me whith this situation?
1 个评论
Geoff Hayes
2017-6-24
Silviu - what are the values for delay1, delay2 and delay3? The pause should not be "summed" so perhaps an incorrect value has been assigned to one or more of these delay variables.
回答(1 个)
The problem must be somewhere else, because the shown code works:
figure;
axes('NextPlot', 'add');
for i = 1:20
p1 = plot(1:10, rand(1, 10));
pause(0.5);
p2 = plot(1:10, rand(1, 10));
pause(0.5);
p3 = plot(1:10, rand(1, 10));
pause(0.5);
delete(p1);
delete(p2);
delete(p3);
drawnow
end
The delays appear exactly where they are wanted.
What is "plot1", "plot2" and "plot3"? What is the purpose of the guidata command?
类别
在 帮助中心 和 File Exchange 中查找有关 Animation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!