Problem with creating video and frame
5 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
Walter Roberson
2025 年 8 月 26 日
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!