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

Walter Roberson
Walter Roberson 2019년 2월 28일
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개)

카테고리

질문:

2019년 2월 28일

댓글:

2019년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by