# Complex Moving Waves

In the previous case, we have seen how can we model a simple wave travelling with one frequency. In nature, usually we encounter waves as an ensemble of many frequencies.

Here, let us try to add more frequencies in the previous scenario:

MATLAB code

```clear; close all; clc

fs=1000;    %sampling frequency

t=0:1/fs:0.5-1/fs;%time

f=[1 2 3];  %frequency1

a=[1 2 3];  %amplitude

c=2; %wave speed

T=1./f;  %time period

w=2*pi*f;   %angular frequency

lb=c*T; %wavelength

k=(2*pi)./lb; %wavenumber

x=0:pi/200:(2.5*pi)-pi/200;

figure('Position',[440 378 800 500])

for i=1:length(t)/2

%     y=a*sin(k*x-w*t(i));    %waveform

y=a(1)*sin((k(1)*x)-(w(1)*t(i))+0.3)+a(2)*sin((k(2)*x)-(w(2)*t(i))+0.4)+a(3)*sin((k(3)*x)-(w(3)*t(i))+0.5);

plot(x,y,'--*')

title('Propagation of waves')

xlabel('x')

ylabel('Amplitude')

grid on

pause(0.05)

end```

In the above code, we plotted wave containing three frequencies. We have modelled the wave in which each frequency is travelling with the same velocity. We can add some complexity where every frequency in our wave is travelling with different speed. This is popularly known as dispersion.

Let us model our waves such that the wave speed for 1,2 and 3 Hz is 0.5,1 and 2 km/s. In this case, we can notice that the waves are travelling in groups and its shape keep changing.

We can use the concept of hilbert transform to model the propagation of the group.  