I attempt to create a movie by looping through frames in MATLAB.
Refering to mathworks.com documentation at http://www.mathworks.com/help/techdoc/ref/movie.html, I've managed to animate a plot. However, issues arise when I attempt to save the movie in an avi file.
Both the avifile
and VideoWriter
methods from https://stackoverflow.com/a/8038540/818608, resulted in the same errors.
Although the animation runs fine, the saved movie consists of only one fixed frame, and at times, the screen capture includes an overlay of my background web browser.
Thank you in advance.
Below is the code I used, and the frame that's frozen on the avi is linked below.
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
vid = VideoWriter('myPeaks2.avi');
vid.Quality = 100;
vid.FrameRate = 15;
open(vid);
for k = 1:20
surf(sin(2*pi*k/20)*Z,Z)
writeVideo(vid, getframe(gcf));
end
close(vid);
winopen('myPeaks2.avi')