A wave is propagating in a closedend tube Compute the wave p
     A wave is propagating in a closed-end tube. Compute the wave propgation up to t=0.15 sec by solving the first-order wave equation partial u/partial r = -a partial u/partial x. Assume the speed of sound to be 200 m/sec. The wave has triangular shape as show in the figure, which is to be used as the initial condition at t=0.0 sec. And Delta x = 1.0 amp Delta t = 0.005  Write a computer program to Solve the problem using Lax method, and the numerical result at (t = 0.15) must be printed in the form of table or plot. Show all statements in your answer.  Where the Lax method is given as:  u_i^n + 1 = 1/2 (u_i + 1^n + u_i - 1^n) - a Delta t/2 Delta x (u_i+1^n - u_i-1^n)  The method is stable when C = a Delta t/Delta x lessthanorequalto 1 
  
  Solution
The matlab script would be as follows:
dx=1;
 dt=.005;
 a=200;
 %%%%intial condition at t=0;
 t(1)=0;
 x=0:dx:70;
 for n=1:71
 u(n,1)=0;
 end
 for n=6:16
 u(n,1)=2*x(n)-10;
 end
 for n=17:26
 u(n,1)=-2*x(n)+50;
 end
 %iterations over t
 m=0.15/dt;
 for n=1:(m-1);
 t(n+1)=t(n)+dt;
 for a=2:70
 u(1,(n+1))=0;
 u(71,(n+1))=0;
 u(a,(n+1))=1/2*(u((a+1),n)+u((a-1),n))-a*dt/2/dx*(u((a+1),n)+u((a-1),n));
  end
 end

