How can I save a animated line into a video?

28 ビュー (過去 30 日間)
Morten Jørgensen
Morten Jørgensen 2019 年 6 月 19 日
編集済み: cui,xingxing 2024 年 4 月 27 日
Hi, I'm trying to save this animated line into a video (mp4)? but I can't make it work.
can anyone help me?
Frames = (1:1:72868)';
h = animatedline;
axis([210,455,-100,140])
x = Frames(210:455,1);
y = accBallXY(210:455,1);
for k = 1:length(x)
addpoints(h,x(k),y(k));
pause(0.04)
drawnow
end

回答 (2 件)

Star Strider
Star Strider 2019 年 6 月 19 日
Start with the getframe function and its firends, then see: Write Sequence of Images to Video.
That should get you started.

cui,xingxing
cui,xingxing 2020 年 4 月 5 日
編集済み: cui,xingxing 2024 年 4 月 27 日
example:
% 阿基米德螺线
theta = 0:0.01:50;
y = theta.*exp(1i*theta);
figure();
h = animatedline(real(y(1)),imag(y(1)));
axis equal;
axis([-50,50,-50,50]);
axis off
[A,map] = rgb2ind(frame2im(getframe),256);
imwrite(A,map,'2.gif','LoopCount',65535,'DelayTime',0.01);
for k = 2:length(theta)
addpoints(h,real(y(k)),imag(y(k)));
drawnow
if(mod(k,20)==0)
[A,map] = rgb2ind(frame2im(getframe),256);
imwrite(A,map,'2.gif','WriteMode','append','DelayTime',0.01);
end
end
-------------------------Off-topic interlude, 2024-------------------------------
I am currently looking for a job in the field of CV algorithm development, based in Shenzhen, Guangdong, China,or a remote support position. I would be very grateful if anyone is willing to offer me a job or make a recommendation. My preliminary resume can be found at: https://cuixing158.github.io/about/ . Thank you!
Email: cuixingxing150@gmail.com
  1 件のコメント
Michele Maria Ciciolla
Michele Maria Ciciolla 2020 年 10 月 25 日
very useful, thank you cui!

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

カテゴリ

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