figure,for j=1:ctr
plot(x,y(:,j))
axis([xlt xrt ylt yrt])
movielist(j) = getframe(gcf);%%%this gets the entire figure.
end
To simply play the created move 'n' times at the frame rate of 'r' per second:
figure,movie(gcf,movielist,n,r)
To save the movie into an avi file
writerObj = VideoWriter('moviefile.avi');
open(writerObj);
for j=1:ctrwriteVideo(writerObj,movielist(j));end
close(writerObj);