MATLAB: VideoWriter — trouble creating the example peaks.avi

videowriter

Windows 7, 64-bit, Matlab R2011a…
I tried running the following code from the VideoWriter examples…
vidObj = VideoWriter('peaks.avi');
open(vidObj);
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
for k = 1:20
surf(sin(2*pi*k/20)*Z,Z)
currFrame = getframe;
writeVideo(vidObj,currFrame);
end
close(vidObj);
This resulted in a faded still image of the first frame. Weirdly, my desktop behind the figure is also visible. I tried…
vidObj = VideoWriter('peaks.avi','Uncompressed AVI');
…which resulted in a video that looked sort of like a scrambled color TV set. Any ideas? Thanks in advance…

Best Answer

set(gcf,'renderer','zbuffer')