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

clc
clear

Resolution=0.1;
Distance=-20:2/10:20;

% ==========================
% ===== The First Wave =====
% ==========================
AmplitudeI=1.2;
WavenumberI=0.5;

   for Time=1:0.2:20
      
      WaveI(fix(Time),1:length(Distance))=AmplitudeI*cos(WavenumberI*(Distance-(1-WavenumberI^2)*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 (Wavenumber = 0.5)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off

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

   for Time=1:0.2:20
      
      WaveII(fix(Time),1:length(Distance))=AmplitudeII*cos(WavenumberII*(Distance-(1-WavenumberII^2)*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 (Wavenumber = 0.85)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off

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

   for Time=1:0.2:20
      
      WaveIII(fix(Time),1:length(Distance))=AmplitudeIII*cos(WavenumberIII*(Distance-(1-WavenumberIII^2)*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 (Wavenumber = 1)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off

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

   for Time=1:0.2:20
      
      WaveIV(fix(Time),1:length(Distance))=AmplitudeIV*cos(WavenumberIV*(Distance-(1-WavenumberIV^2)*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 (Wavenumber = 1.1)');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off

% ==========================
% ===== The Fifth Wave =====
% ==========================
AmplitudeV=0.7;
WavenumberV=1.3;

	for Time=1:0.2:20
   
      WaveV(fix(Time),1:length(Distance))=AmplitudeV*cos(WavenumberV*(Distance-(1-WavenumberV^2)*Time));

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

% ===============================
% ===== The Dispersive Wave =====
% ===============================
   %for Time=1:0.2:20
      
      DispersiveWave=WaveI+WaveII+WaveIII+WaveIV+WaveV;

   %end
      
figure(6);
PropagationParameter=[1:Resolution:Time];
PropagationEvolution=DispersiveWave(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('The Dispersive Wave');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');