
アニメーションとしての保存方法
    5 views (last 30 days)
  
       Show older comments
    
comet(a,b)
でアニメーション動画を出したものをaivで保存したいのですが、分かる方教えて頂きたいです。 helpも見てみたのですが、 matlab初心者なので、複雑でよく分からなかったです。 宜しくお願い致します。
0 Comments
Accepted Answer
  Kenta
      
 on 12 Jun 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形式も可能です。
0 Comments
More Answers (0)
See Also
Categories
				Find more on アニメーション in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!