% Set up parameters %Diffusion coefficient a=1; %Boundary conditions alpha=0; delta=0; %Time step k=0.01; Tn = 20; %Spatial variables L=2; h=0.2; M = int16(L/h)-1; %Assume for now that there are 10 time steps, so the final time is 0.1. I %am setting up an M+2 by Tn+1 array that will hold all solutions. The extra 1 in Tn + 1 is %there to store the initial conditions. u=zeros(M+2,Tn+1); % Setting up initial conditions x=[0:h:L]'; u(:,1)=sin(pi/2*x); %Puts the initial conditions in the first column of u % Forward difference in time / central difference in space *************** % End ************************************* plot(x,u(:,1),'k',x,u(:,Tn),'r')