clear all;
h = 0.001;
tau = 0.0005;
x = 0:h:7;
t = 0:tau:10;
N = length(x);
M = length(t);
u = zeros([N,M]);
for m = 1:M
   u(1,m)= 0;
   u(N,m)= 0;
end
for n = 1:N
	if x(n) >= 3/2 & x(n) <= 7/2;
	   u(n,1) = cos(pi*x(n)) * cos(pi*x(n));
	if x(n) <= 3/2 & x(n) >= 7/2;
	   u(n,2) = 0;
	end
	end
end
for m = 2:(M - 1)
   for n = 2:(N - 1)
       u(n,m+1) = 2*u(n,m) - u(n,m-1) + tau^2/h^2*(u(n+1,m)-2*u(n,m)+u(n-1,m));
   end
end
for m = 1:M
   plot(x,u(:,m))
   axis([-10,10,-10,10])
   MM(m)= getframe;
end
movie(MM,3)


