%==========================================
%===== Solutions to the Wave Equation =====
%==========================================

clc
clear

Distance=-20:2/10:20;

AmplitudeI=1;
VelocityI=0.25;
   
   for Time=1:0.2:20
      
     WaveI(fix(Time),1:length(Distance))=AmplitudeI*sin(Distance-(VelocityI*Time))./(Distance-(VelocityI*Time));
    %WaveI(fix(Time),1:length(Distance))=AmplitudeI*cos(Distance-(VelocityI*Time));

   end
      
figure(1);
PropagationParameter=[1:1:Time];
PropagationEvolution=WaveI(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('Wave I (Velocity=0.25)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off
   
%=======================================
%=======================================

AmplitudeII=1.2;
VelocityII=-0.25;
   
   for Time=1:0.2:20
      
     WaveI(fix(Time),1:length(Distance))=AmplitudeII*sin(Distance-(VelocityII*Time))./(Distance-(VelocityII*Time));
    %WaveI(fix(Time),1:length(Distance))=AmplitudeII*cos(Distance-(VelocityII*Time));

   end
      
figure(2);
PropagationParameter=[1:1:Time];
PropagationEvolution=WaveI(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('Wave II (Velocity=-0.25)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off