Save video from comet command

7 ビュー (過去 30 日間)
Kostas Sita
Kostas Sita 2016 年 10 月 17 日
コメント済み: Kostas Sita 2016 年 10 月 27 日
I use a comet command in my code to plot a graph (e.g. comet(x,y)). I want to save this in a video format to show it in a Powerpoint prresentation. How can I do it?

採用された回答

KSSV
KSSV 2016 年 10 月 17 日
編集済み: KSSV 2016 年 10 月 17 日
Instead of video, it is better to go for .gif file. See the example code below:
clc; clear all ;
x = 0:0.01:1;
figure(1)
filename = 'mygif.gif';
t = linspace(0,2*pi) ;
x = sin(pi*t) ;
for n = 1:length(t)
plot(t(1:n),x(1:n))
axis([min(t) max(t) min(x) max(x)]) ;
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
  3 件のコメント
KSSV
KSSV 2016 年 10 月 17 日
Kostas Sita
Kostas Sita 2016 年 10 月 27 日
Perfect! Thanks a lot!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by