clear
nx=1000;
nt=2000;
dt = .01;

dx = 10/(nx-1);

X=0:dx:10;

u=zeros(1,nx);
uo=zeros(1,nx);
un=zeros(1,nx);


c=1;
lc=1;
dlc=50;

c1=dt^2*c^2/dx^2;

for n=1:nt
    if n<=314 
        u(1) = sin(2*(n)*dx);
    end
     if 1 == 1
    if n > 1000 & n<=1314
        %u(1) = sin(2*(n-1000)*dx);
        u(1) = 1;
    end
    if n == 1315
        u(1) = 0;
    end
    
     end
   for i = 2:nx-1
       un(i) = 2*u(i) - uo(i) + c1*(u(i+1) -2*u(i) +  u(i-1));
    end
    
    
    uo=u; % curent become old
    u=un; % new become current
    
    if mod(n-1,dlc)==0
        figure(lc)
        plot(X,u)
        shg
        lc=lc+1;
    end
 
    
   
end
    
plot(u)

    
    
    
                
                

