アニメーションとしての保存方法

21 visualizaciones (últimos 30 días)
sz
sz el 12 de Jun. de 2020
Respondida: Kenta el 12 de Jun. de 2020
comet(a,b)
でアニメーション動画を出したものをaivで保存したいのですが、分かる方教えて頂きたいです。 helpも見てみたのですが、 matlab初心者なので、複雑でよく分からなかったです。 宜しくお願い致します。

Respuesta aceptada

Kenta
Kenta el 12 de Jun. de 2020
clear;clc;close all
t = 0:.01:pi;
x = cos(2*t).*(cos(t).^2);
y = sin(2*t).*(sin(t).^2);
figure;plot(x,y);hold on
filename = 'testAnimated.gif';
for i=1:numel(x)
scatter(x(i),y(i),'r')
frame = getframe(gcf);
im = frame2im(frame);
[A,map] = rgb2ind(im,256);
if i == 1
imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',.01);
else
imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',.01);
end
end
できるのかもしれませんが、comet関数の途中で止めたり保存したりすることは難しい気がします。for文で各tの値でプロットしながら保存するのはいかがでしょうか。上は表示のためGIFですが、AVI形式も可能です。

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!