How to animate different plots at the same time using subplot, addpoints and animatedline?
Mostrar comentarios más antiguos
I am trying to animate tow distinct graphics simultanneosly using addpoins ane subplot. The two graphics should shown side by side, that is, in different cells (separated by subplot) while are being animated. However, the graphics are shown toghether on the seme cell.
Cound anyone help me to sove this problem?
Attached is the result the code output.
That is the code I have used:
t = 0:pi/20:10*pi;
% First graphic
subplot(1,2,1)
y1 = sin(t);
plot(t,y1)
% second graphic
subplot(1,2,2)
y2= sin(t+pi/2);
plot(t,y2)
curve1 = animatedline('LineWidth', 2);
curve2 = animatedline('LineWidth', 2);
for i = 1: length(t)
addpoints(curve1, t(i), y1(i));
drawnow
addpoints(curve2, t(i), y2(i));
% head = scatter(t(i), y(i));
drawnow
pause(0.01);
% delete(head);
end
Respuesta aceptada
Más respuestas (1)
Oghenetega Oguns
el 6 de Jun. de 2022
0 votos
Thanks. This works for me
Categorías
Más información sobre Animation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!