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

clc
clear

Distance=-20:2/10:20;

Amplitude=1;
Wavenumber=0.5;
   
   for Time=1:0.2:20
      
      DissipativeWave(fix(Time),1:length(Distance))=Amplitude*cos(Wavenumber*(Distance-Time)).*exp(-Wavenumber^2*Time);
      
   end
      
figure(1);
PropagationParameter=[1:0.5:Time];
PropagationEvolution=DissipativeWave(PropagationParameter,:);
mesh(Distance,PropagationParameter,PropagationEvolution);
h1=mesh(Distance,PropagationParameter,PropagationEvolution);
set(h1,'MeshStyle','row');
title('The Dissipative Wave');
xlabel('Time');
ylabel('Distance');
zlabel('Amplitude');
hidden off