% =========================================================================
% ===== The Wave Equation: Utt - (1/c^2) Uxx=0 (D'Alembert Solutions) =====
% =====                     [Initial Zero Velocity]                   =====
% =========================================================================

clc
clear

Time=-8:1/1000:8;
Velocity=0.5;
Seperation=-8;

for Distance=1:2*abs(Seperation)
   
   EnvelopeI(fix(Distance),1:length(Time))=exp(-(Time-Velocity*Seperation).^2/2);
	EnvelopeII(fix(Distance),1:length(Time))=exp(-(Time+Velocity*Seperation).^2/2);
   WaveForm(fix(Distance),1:length(Time))=EnvelopeI(fix(Distance),1:length(Time))+EnvelopeII(fix(Distance),1:length(Time));
   Seperation=Seperation+1;

end

figure(1);
PropagationParameter=[1:1:Distance];
PropagationEvolution=WaveForm(PropagationParameter,:);
mesh(Time,PropagationParameter,PropagationEvolution);
h1=mesh(Time,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('The Wave Equation: Utt - (1/c^2) Uxx=0 (D Alembert Solutions)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
axis tight
hidden off