I want to generate a movie of time-dependent simulation results in Matlab by inserting the following commands at the end of the program in the plot statement. However, the figure stops at the first frame, but if I comment out the last two lines about the movie, the code shows the time-dependent result during running but does not generate any movie.
I understand that in Matlab there are several ways to do that, but what I want is a simplest way. That is to insert the two line, actually one line, which should be something like:
eval(['print -dpict ','temp',num2str(is)]);
in the plot statement to print out each frame as a picture file, and then assemble them into a movie. My plotting code is as follows. Could you please suggest me how to fix this? Thank you very much.
time=time+dt % plot the results
uu(1:nx+1,1:ny+1)=0.5*(u(1:nx+1,2:ny+2)+u(1:nx+1,1:ny+1));
vv(1:nx+1,1:ny+1)=0.5*(v(2:nx+2,1:ny+1)+v(1:nx+1,1:ny+1));
for i=1:nx+1,xh(i)=dx*(i-1);end; for j=1:ny+1,yh(j)=dy*(j-1);end
hold off,contour(x,y,flipud(rot90(r))),axis equal,axis([0 Lx 0 Ly]);
hold on;quiver(xh,yh,flipud(rot90(uu)),flipud(rot90(vv)),'r');
pause(0.01);
% movie_str = ['print -dpict','temp',num2str(is)]; % generate a movie
% eval(movie_str); pause(0.01);
end