How to save figure frames as gif file?
343 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ashfaq Ahmed
le 12 Avr 2022
Réponse apportée : Ashfaq Ahmed
le 13 Avr 2022
Hi all,
I am having a problem while saving my figure frames as a gif file. I am using this code -
for i = 1:Leng
figure(1);
hold on
title(['Time = ' num2str(t(i))]);
plot(px(i,:),py(i,:),'o','MarkerSize',4,'color',[1 0 0]);
pause(0.2);
F(i) = getframe(gcf);
drawnow
end
%Making mnovie
writerObj = VideoWriter('Particle02.gif');
writerObj.FrameRate = 10;
open(writerObj);
% write the frames to the video
for i=1:length(F)
frame = F(i) ;
writeVideo(writerObj, frame);
end
% close the writer object
close(writerObj)
Although I am saving it as '.gif' file, it is being saved as '.avi' file.
Can anyone please help? Any feedback will be much appreciated!
0 commentaires
Réponse acceptée
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!