필터 지우기
필터 지우기

Pausing and continuing an animation in App Designer

조회 수: 3 (최근 30일)
R.S.
R.S. 2020년 11월 7일
댓글: MSolano 2021년 7월 7일
Hey everyone I'm trying to pause an animation I made.
Following is the loop that generates the animation.
Before, the position over time of the falling objects are calculated and saved as a vector.
Objects are generated by the patch command.
With every iteration of the loop the new position is shown in a figure.
tu is the time the objects fall until they hit the ground.
tf is a vector with the time intervals between 0 and tu.
tf consists of as many columns as needed to guarantee 25 frames per seconds.
So far everything works as planed.
%Schleife zur Animation
q = 1;
time = 0;
tic;
while time < tu
time = toc;
%Anzeigewerte
app.GeschwindigkeitEditField.Value = vt(q);
app.aktuelleZeitEditField.Value = tf(q);
app.StreckeEditField.Value = st(q);
app.kinetischeEnergieEditField.Value = Ekin(q);
app.potentielleEnergieEditField.Value = Epot(q);
app.GesamtenergieEditField.Value = Eges(q);
app.rotatorischeEnergieEditField.Value = 0; % visualisation of Information about velocity, energy, time etc.
%Position der Scheibe
Kreis.XData = xAkreis + R;
Kreis.YData = yAkreis + y(q); % positon of first falling object
InnenKreis.XData = xIkreis + R;
InnenKreis.YData = yIkreis + y(q); % positon of second falling object
%Grenzen des Diagramms
xlim([-R 20+R]);
ylim([-H-Boden*3/2 R+2]);
pau = tf(q) - toc;
pause(pau); % forcing matlab to wait until predefined time (tf)
q = q + 1;
if q > length(tf)
q = length(tf);
end
end
I now want to pause my animation at any point and continue it at the same point.
I tried a second infinite while loop inside the first one that is started by using a switch in app designer but if it started it started with different delays and didn't continue after I used the switch again.
Thanks for any help!
  댓글 수: 4
Mario Malic
Mario Malic 2020년 11월 8일
Great! I'll post this as an answer and you can accept it. Thanks in advance.
MSolano
MSolano 2021년 7월 7일
I'm having a very similar issue, but I just can't find the answer, how were you able to solve this?? Just with the if and while loops inside your animation loop?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by