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
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 件)

Jan
Jan 2017 年 6 月 24 日
編集済み: Jan 2017 年 6 月 24 日

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?

質問済み:

2017 年 6 月 24 日

編集済み:

Jan
2017 年 6 月 24 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by