
clear; clc;

x = -3:.2:3;
y = -3:.2:3;
[xx,yy] = meshgrid(x,y);
zz = peaks(xx,yy);

figure(1)
surf(xx,yy,zz)
axis off


figure(2)

pcolor(x,y,zz);
hold on
axis([-3 3 -3 3]);
colormap((jet+white)/2);
shading interp
[px,py] = gradient(zz,.2,.2);
quiver(x,y,px,py,2,'k');
axis off
hold off
colorbar


figure(3)
N=30;
k=0;
mov = avifile('example.avi');
for j = 1:N
    Z2=zz*cos(k);
    surf(xx,yy,Z2)
    axis([-3 3 -3 3 -10 10]);
    axis off
     F = getframe(gca);
     mov = addframe(mov,F);
    k = k+2*pi/N;
end
mov = close(mov);



figure(4)
k=0;
mov2 = avifile('example2.avi');
for j = 1:N
Z2=zz*cos(k);
pcolor(x,y,Z2);
hold on
axis([-3 3 -3 3 -10 10]);
colormap((jet+white)/2);
shading interp
[px,py] = gradient(Z2,.2,.2);
quiver(x,y,px,py,2,'k');
axis off
hold off
     F2 = getframe(gca);
     mov2 = addframe(mov2,F2);
    k = k+2*pi/N;
    
end

mov2 = close(mov2);