Problem with creating video and frame
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Neda
am 26 Aug. 2025
Beantwortet: Walter Roberson
am 26 Aug. 2025
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Aug. 2025
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!