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