フィルターのクリア

How to create a 2D line plot animation

10 ビュー (過去 30 日間)
Jimmy Neutron
Jimmy Neutron 2021 年 1 月 12 日
回答済み: Jimmy Neutron 2021 年 1 月 12 日
I have a double array of 2001 values which is recorded from SImulink in 20 seconds. When I try to create a video animation of the graph plotting, I get an output of 1:06 minutes. Is there a way to create an animation that would correlate to the original 20 seconds and save it as an mp4 file directly? Here is my code:
load("test1.mat");
video = VideoWriter('test1','MPEG-4');
open(video)
curve = animatedline('Color','r');
set(gca, 'XLim', [0 2001],'YLim', [-200 200])
grid on
for i=1:2001
addpoints(curve,i ,val(i));
drawnow
writeVideo(video,getframe(gcf));
end
close(video);

採用された回答

Jimmy Neutron
Jimmy Neutron 2021 年 1 月 12 日
It is a matter of frames per second - as the recording were done at a sample rate of 0.01, the fps was set to 100. Here is te code:
load("test1.mat");
video = VideoWriter('test1','MPEG-4');
video.FrameRate = 100;
open(video)
curve = animatedline('Color','r');
set(gca, 'XLim', [0 20],'YLim', [-200 200])
grid on
for i=1:2001
addpoints(curve,i*0.01 ,val(i));
drawnow
writeVideo(video,getframe(gcf));
end
close(video);

その他の回答 (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