MATLAB: Does a movie get stored incorrectly when using the axis contents but not when using the figure contents in MATLAB 6.5 (R13)

animationaxesMATLABmovie

When I run the following code to create a movie, the file is created with incorrect screen information when the axes contents are used to create the movie.
Z = peaks;
surf(Z)
axis tight
set(gca,'nextplot','replacechildren');
for j = 1:20
surf(sin(2*pi*j/20)*Z,Z)
F(j) = getframe(gca);
end
movie2avi(F,'testcon1.avi','compression','Indeo5');
However, if the figure contents are used instead, the movie is generated correctly.

Best Answer

This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
There is a bug in the GETFRAME function in MATLABL 6.5 (R13) when used with the handle to the axis or without any arguments. Either extraneous screen information is also added to the movie or insufficient screen information is included.
To work around this issue use the GETFRAME function with the handle to the figure window as the argument:
getframe(gcf);