Patch error on m_plots

In a for loop, I am plotting frames of a GIF. There are two subplots, two 'm_pcolor', one 'm_quiver'. These are from the m_map toolbox. I am using the following code to get the GIF made: (If I comment this, the error still remains)
drawnow
filename = 'testnew.gif';
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if time_loop == 1
imwrite(imind,cm,filename,'gif','Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
The error I get for every loop is:
Warning: Error creating or updating Patch
Error in value of property FaceVertexCData
Number of colors must equal number of vertices
If I remove the for loop and run the code inside the loop on its own, everything works fine. Everything plots OK, but seems slower with the error.
What does the error mean? Is there any solution?

1 个评论

Is the error showing up at the drawnow() ? Is it showing up at the getframe() call?
It looks like you are hard-coding fetching frames from figure #1, using old style figure numbers (that does still work even in the latest releases, by the way.)
Is it correct that you have a patch() object in your figure?

请先登录,再进行评论。

回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by