In this video we will see a practical application of the wavelet concepts we learned earlier
I will illustrate how to obtain a good time frequency analysis of a signal using the continuous wavelet transform
To begin, let us load an earthquake signal in MATLAB
This signal is sampled at 1 Hertz for a duration of 51 minutes
You can view the signal using the plot command
Looking at the time domain representation of the signal
We see two distinct regions
The first seismic activity occurs around the 30 minute mark
This lasts for a very short duration
The second seismic activity occurs sometime around 34 minutes and is relatively longer
You can see how it is difficult to separate the noise from the seismic signals just by looking at the time domain representation
Many naturally occurring signals have similar characteristics
They are composed of slowly varying components interspersed with abrupt changes and are often buried in noise
Wavelets are very useful in analyzing these kinds of signals, we will see how a bit later
But first, let us see what happens when we use the short time Fourier transform to produce a time frequency visualization
We pass the signal and the sampling frequency as input arguments to the function spectrogram
Looking at the output, you can see that the two instances of seismic activity we just saw are now indistinguishable
All we see is a signal whose frequency is spread around point zero five Hertz but it is not very well localized
Let us see what happens when we try to localize the events by reducing the window size used in the spectrogram
By reducing the size of the window we see some bright spots around 30 and 33 minutes but the two events are not well separated
The frequency and the time uncertainty of the events is still very high
Reducing the window size was not very helpful
We need to somehow localize the frequency information of these two events
Let us now repeat the analysis, this time using wavelets
We will use the CWT function in MATLAB to compute the continuous wavelet transform
This will help obtain a joint time frequency analysis of the earthquake data
The CWT function supports these key analytic wavelets
If you do not specify which wavelet you want to use the CWT uses Moore's wavelets by default
When no output parameters are specified the function CWT produces a joint time frequency visualization of the input signal
The minimum and the maximum scales for the analysis are determined automatically by the CWT function based on the wavelets energy spread
The magnitude of the wavelet coefficients returned by the function are color-coded
The white dashed line denotes the cone of influence
Within this region, the wavelet coefficient estimates are reliable
Looking at the plot, we can see the two regions produced by the earthquake
The first seismic activity is clearly separated from the second
Both these events seem to be well localized in time and frequency
For a richer time frequency analysis, you can choose to vary the wavelet scales or which you want to carry out the analysis
You can do this by using other input parameters
For this example, we will set the number of octaves parameter to 10 and the number of voices per octave parameter to 32
The function returns the wavelet coefficients and the equivalent frequencies as outputs
We can plot the wavelet coefficients as a function of time and frequency using the surface command
Looking at this plot, it is clear that the frequency of the seismic event ranges from point zero three Hertz to point zero six Hertz
We can also reconstruct the time domain representation of the seismic event from the wavelet coefficients using the function "icwt"
We pass in the wavelet coefficients and the frequency vector which is the output of the CWT function
We also pass in the frequency range of the signal that we want to extract
In this case, we are inputting .03 to .06
The output is a time domain representation of the seismic signal of interest
This way you can use wavelets for performing joint time frequency analysis