clear all; close all; clc; N=25; L=1; x2=linspace(-L,L,N+1); x=x2(1:N); dx=x(2)-x(1); k=.01; e=ones(N,1); A=spdiags([e -2*e e],-1:1,N,N); A(1,N)=1; A(N,1)=1; tspan=[0 10]; y2=linspace(-L,L,N+1); y=y2(1:N); dy=y(2)-y(1); I=eye(N,N); B=kron(I,A)+kron(A,I); [X,Y]=meshgrid(x,y); U0=exp(-X.^2-Y.^2); uu0=reshape(U0,N^2,1); [t,uu]=ode45('pderhsnew',tspan,uu0,[],k,dx,B,N); for i=1:length(t) surf(X,Y,reshape(uu(i,:),N,N)) axis([-1 1 -1 1 0 1]) F(i)=getframe; end movie(F)