xmin=min(x(:)); xmax=max(x(:));
ymin=min(y(:)); ymax=max(y(:));
xmid=(xmin+xmax)/2; ymid=(ymin+ymax)/2;
d=max(xmax-xmin,ymax-ymin)/2; Nt=length(t);
range=[xmid-d,xmid+d,ymid-d,ymid+d,...
       3*min(u(:)),3*max(u(:))];
s=size(u);
N=s(3);
surf(x,y,u(:,:,1))
axis(range)
shading interp
colormap copper
view(2)
axis square

set(gca,'NextPlot','replacechildren');
%F(20) = struct('cdata',[],'colormap',[]);
% Record the movie
for j = 1:N 
    surf(x,y,u(:,:,j))
    axis(range)
    shading interp
    colormap copper
    view(2)
    axis square
    F(j) = getframe;
end

% Uncomment next line to create movie in avi format
%movie2avi(F, 'myMovie.avi', 'compression', 'None');