MATLAB: Do i get error in videowriter as “Error using VideoWriter/writeVideo Frame must be 436 by 344 Error in videoominusone (lwriteVid​eo(writerO​bj,getfram​e(gca));”

MATLABvideowriter

Please help me to solve this errror
Error using VideoWriter/writeVideo (line 383)
Frame must be 436 by 344
Error in videoominusone (line 286)
writeVideo(writerObj,getframe(gca));

Best Answer

Every frame that you write with VideoWriter must be the exact same size.
getframe(gca) returns according to the current axes size. If you have not taken special care, that axes size will not necessarily be exactly the same size as the previous frame.
You should be considering setting up the axes once and using "hold on", and then updating only the content of the axes. Your current code likely rebuilds the axes each time through your loop.