%=======================================================================
%===== Solution to the Wave Equation with Dispersion & Dissipation =====
%=======================================================================

clc
clear

Resolution=0.2;
TimeDuration=20;
Distance=-10:2/10:10;

% ==========================
% ===== The First Wave =====
% ==========================
AmplitudeI=1;
VelocityI=8;
DeltaI=2;
GammaI=0.1;
WavenumberI=0;

	for Time=1:0.2:TimeDuration
   
      WaveI(fix(Time),1:length(Distance))=AmplitudeI*cos(WavenumberI*(Distance-(VelocityI-WavenumberI^2*DeltaI)*Time)).*exp(-WavenumberI^2*GammaI*Time);

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

% ===========================
% ===== The Second Wave =====
% ===========================
AmplitudeII=0.8;
WavenumberII=1.5;

   for Time=1:0.2:TimeDuration
      
      WaveII(fix(Time),1:length(Distance))=AmplitudeII*cos(WavenumberII*(Distance-(VelocityI-WavenumberII^2*DeltaI)*Time)).*exp(-WavenumberII^2*GammaI*Time);

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

% ==========================
% ===== The Third Wave =====
% ==========================
AmplitudeIII=1.2;
WavenumberIII=2;

   for Time=1:0.2:TimeDuration
      
      WaveIII(fix(Time),1:length(Distance))=AmplitudeIII*cos(WavenumberIII*(Distance-(VelocityI-WavenumberIII^2*DeltaI)*Time)).*exp(-WavenumberIII^2*GammaI*Time);

   end
      
figure(3);
PropagationParameter=[1:Resolution:Time];
PropagationEvolution=WaveIII(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('Wave III');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off

% ===========================
% ===== The Fourth Wave =====
% ===========================
AmplitudeIV=1.5;
WavenumberIV=2.5;

   for Time=1:0.2:TimeDuration
      
      WaveIV(fix(Time),1:length(Distance))=AmplitudeIV*cos(WavenumberIV*(Distance-(VelocityI-WavenumberIV^2*DeltaI)*Time)).*exp(-WavenumberIV^2*GammaI*Time);

   end
      
figure(4);
PropagationParameter=[1:Resolution:Time];
PropagationEvolution=WaveIV(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('Wave IV');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off

% ===============================================
% ===== The Dispersive and Dissipative Wave =====
% ===============================================
DispersiveAndDissipativeWave=WaveI+WaveII+WaveIII+WaveIV;

figure(5);
PropagationParameter=[1:0.5:Time];
PropagationEvolution=DispersiveAndDissipativeWave(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('The Dispersive and Dissipative Wave');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off