%
clc
h = figure;
Z = peaks;
surf(Z)
pause
axis tight manual
ax = gca;
ax.NextPlot = 'replaceChildren';
loops = 40;
M(loops) = struct('cdata',[],'colormap',[]);
pause
h.Visible = 'off';
for j = 1:loops
    X = sin(j*pi/10)*Z;
    surf(X)
    drawnow
    M(j) = getframe;
end
h.Visible = 'on';
pause
%movie(M);
close
movie2gif(M,'peak.gif')
%
