clear;
N = 30; % Anzahl Bilder

[X,Y] = meshgrid(-pi:.1:pi);
M = moviein(N); % Initialisierung

for t = 1:N
    Z = cos(X-t*pi/N).*sin(Y-t*pi/N);
    surf(X,Y,Z);
    axis([-pi pi -pi pi -1 1]);
    xlabel('x');
    ylabel('y');
    zlabel('f(x,y,t)');
    colorbar
    M(:,t) = getframe;
    
end

%movie(M,2);

myVideo = VideoWriter('myfile.avi');
myVideo.FrameRate = 5;
open(myVideo);
writeVideo(myVideo, M);
close(myVideo);