Making a video for 1000 time-steps

조회 수: 4 (최근 30일)
Neda
Neda 2024년 12월 10일
댓글: Neda 2024년 12월 11일
Hi Matlab Team,
The output of my code is the movement of cells in 1000 time-steps, I arrange the code such that I can see the result in each time-step. Now, I want to create a video from all the frames. Would you please let me know, how can I do this?
Thank you !!!

채택된 답변

Walter Roberson
Walter Roberson 2024년 12월 10일
writerObj = VideoWriter('OutputFileNameGoesHere.avi');
ax = gca;
oldsize = [0 0];
for timestep = 1 : 1000
%do appropriate plotting here
%...
F = getframe(ax);
if timestep == 1
oldsize = [size(F.cdata,1), size(F.cdata,2)];
else
F.cdata = imresize(F.cdata, oldsize);
end
writeVideo(writerObj, F);
end
close(writerObj);
  댓글 수: 3
Voss
Voss 2024년 12월 10일
writerObj = VideoWriter('OutputFileNameGoesHere.avi');
open(writerObj);
% then the rest of the code is the same ...
ax = gca;
% etc.
Neda
Neda 2024년 12월 11일
Thank you so much. It works well !!! :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by