% Showing solution of Utt - c Uxx =0 that has initial zero velocity x=-8:0.05:8; t=-8:0.05:8; [X,T]=meshgrid(x,t); set(gca,'FontSize',[16]); figure(1) c = 0.5; Z1=exp(-(X-c*T).^2/2); Z2=exp(-(X+c*T).^2/2); Z=Z1+Z2; surfl(X,T,Z); shading interp colormap(gray) ylabel('t') xlabel('x') zlabel('u(x,t)') view([15 52]) axis tight steps=4; N=length(t(1:steps:length(t))); xM=max(max(x)); xm=min(min(x)); M=max(max(Z)); m=0; figure(2) clf fprintf('Press any key to continue\n') i=1; plot(x,Z(i*steps+1,:),'LineWidth',2) axis([xm xM 0 M]) pause set(gca,'FontSize',[16]); for i=0:N-1 plot(x,Z(i*steps+1,:),'LineWidth',2) axis([xm xM 0 M]) pause(0.01) end steps=1; N=length(t(1:steps:length(t))); figure(3) clf i0=(N+1)/2; plot(x,Z(i0*steps+1,:),'LineWidth',2) axis([xm xM 0 M]) fprintf('Press any key to continue\n') pause set(gca,'FontSize',[16]); for i=i0:N-1 plot(x,Z(i*steps+1,:),x,2*Z2(i*steps+1,:),x,2*Z1(i*steps+1,:),'r','LineWidth',2) axis([xm xM 0 M]) pause(0.01) end