Saving animation of projectile motion
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Christo van Rensburg
el 6 de Ag. de 2019
Comentada: Christo van Rensburg
el 7 de Ag. de 2019
Hi there
I'm struggling to find a way of saving three projectiles on the same graph as a video file. I have three for loops for each iteration that looks like this:
for i1=1:length(Y1(:,1))
addpoints(curve1,Y1(i1,1),Y1(i1,2));
drawnow
pause(0.1)
end
And then the code that actually saves only a piece of the animation so far is:
F(i2) = getframe(gcf);
video = VideoWriter('trajectories.avi', 'MPEG-4');
open(video)
writeVideo(video, F);
close(video)
Please help, it only saves the last trajectory.
Thanks!
2 comentarios
Respuestas (2)
darova
el 7 de Ag. de 2019
Am i correct?
video = VideoWriter('trajectories.avi', 'MPEG-4');
open(video)
for i1 = 1:n1
% draw something
F = getframe;
writeVideo(video, F);
pause(0.02);
end
for i2 = 1:n2
% draw something
F = getframe;
writeVideo(video, F);
pause(0.02);
end
for i3 = 1:n3
% draw something
F = getframe;
writeVideo(video, F);
pause(0.02);
end
close(video)
Or you want three curves drawing simultaneously?
Ver también
Categorías
Más información sobre Animation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!