필터 지우기
필터 지우기

How to make a video from comet(x, y) command?

조회 수: 8 (최근 30일)
Mark
Mark 2023년 11월 6일
답변: Walter Roberson 2024년 1월 2일
I am trying to record a movie using the comet(x, y) command. To record a movie I use the following commands:
drawnow
movieVector(k) = getframe(gcf);
these are inside a lopp and:
v = VideoWriter('L3 Orbits', 'MPEG-4');
v.FrameRate = 100;
open(v);
writeVideo(v, movieVector)
close(v);
which are outside of the loop.
The issue is I need to capture more frames than just one frame per trajectory. I don't know how to do this.

채택된 답변

Walter Roberson
Walter Roberson 2024년 1월 2일
You cannot do this while using comet() . comet() does not return until all of the drawing is complete .
These days comet() is implemented in terms of animatedLine() and addpoints() and drawnow() . That is probably the same strategy you should use to create the movie.

추가 답변 (1개)

Balaji
Balaji 2023년 11월 7일
Hi Mark,
To capture more frames per trajectory when recording a movie using the `comet` command in MATLAB, you can modify your code as follows:
v = VideoWriter('L3 Orbits', 'MPEG-4');
v.FrameRate = 100;
open(v);
for k = 1:numTrajectories
comet(x, y);
numFramesPerTrajectory = 100;
movieVector = struct('cdata', cell(1, numFramesPerTrajectory), 'colormap', cell(1, numFramesPerTrajectory));
for frame = 1:numFramesPerTrajectory
drawnow;
movieVector(frame) = getframe(gcf);
end
writeVideo(v, movieVector);
end
close(v);
Thanks,
Balaji
  댓글 수: 2
Mark
Mark 2023년 11월 7일
I still do not get a video output.
I've attached the main script 'Comet_Plot.m' and the supporting function files: 'pcr3bp.m', 'trajGet3BP.m', and 'Rotation_Rot2Iner.m'.
Balaji
Balaji 2024년 1월 2일
Please insert the following line of code after the `movie_vector` has finished updating, at line 109 in `Comet_Plot.m`:
writeVideo(v, movieVector);

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

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by