LoginSignup
5
5

More than 5 years have passed since last update.

Matlab: figureをビデオに書き込む

Last updated at Posted at 2015-05-31

プロットをビデオファイルに書き込んでいく方法.
VideoWriterクラスオブジェクトを作成して, open, writeVideo, closeメソッドで書き込む.

ビデオファイル形式 > doc VideoWriter
書き込めるオブジェクト形式 > doc writeVideo
レンダリングは'opengl'がデフォルト(doc Figureのプロパティ > Renderer)

figure_to_video
x = 0:100;
y = sin(x);

writerObj = VideoWriter('test.avi');
open(writerObj);

fig = plot(x,y);
set(fig, 'XDataSource', 'x');
set(fig, 'YDataSource', 'y');
set(gca, 'Xlim', [0 100], 'Ylim', [-20 20]);
set(gca,'nextplot','replacechildren');

for k = 0:20
    y = k*sin(x);
    refreshdata(fig);

    frame = getframe(gcf);
    writeVideo(writerObj, frame);
end

close(writerObj);

イメージとしての保存
http://qiita.com/jellied_unagi/items/7f2f7529bafcbcd5f5d3

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5