Dear Matlab Team,
I have a question regarding creating the video.
I have this, at the beginnig of my code, before the "for t=1:1000"
fig = figure('Position', [100, 100, 1924, 975]);
axis tight manual;
------------------------
drawnow;
frame = getframe(fig);
writeVideo(writerObj, frame);
-------------------------
But still get the error:
Error using VideoWriter/writeVideo
Frame must be 1924 by 975
Error in testfile (line 741)
writeVideo(writerObj, frame);
Thank you

 채택된 답변

Walter Roberson
Walter Roberson 2025년 8월 26일

0 개 추천

The second and each following frame of video must be the same size as the first frame that is written.
Each time you draw a new plot, there is the possibility that getframe() of it might be a slightly different size, even if the figure size and axes size remains exactly the same.
In particular, the algorithm for automatically labeling axes has a little bit of slop for the position of the rightmost characters. Because of that, the captured axes width can be up to 2 pixels shorter than normal, or up to 5 pixels wider than usual.
One typical work-around is to imresize() the second and following captured frames to be the same size as the first captured frame.

추가 답변 (0개)

태그

질문:

2025년 8월 26일

답변:

2025년 8월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by