% =========================
% = The Longitudinal Wave =
% =========================
clc
clear
Amplitude=2;
%The wave completes three full cycles per second
Frequency=3;
%We convert the frequency value to angular frequency
AngularFrequency=2*pi*Frequency;
%The sampling rate (only for the purpose of translating the wave to a digital form)
SamplingRate=50;
%The phase value for a Sine wave
Phase=0;
%The maximum duration of the wave [either in time (1 Sec) or in distance (1 m)] 
TimeDistance=0:1/SamplingRate:0.4;

%The longitudinal wave
LongitudinalWave=Amplitude*sin(AngularFrequency*TimeDistance + Phase);

[x,y]=meshgrid(LongitudinalWave);
quiver(x,y);
title ('The Longitudinal Wave');
xlabel ('Time or Distance');
ylabel ('Amplitude');
grid on