# Understanding Wavelets, Part 4: An Example Application of Continuous Wavelet Transform

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

## 16 thoughts on “Understanding Wavelets, Part 4: An Example Application of Continuous Wavelet Transform”

1. Gaston Maciel says:

espectacular

2. USS Trekky says:

Cool

3. Mayank Kumar says:

Dear Sir, is the 'cwt' command applicable to a vector or a .wav object ? I have a row vector which I need to analyse using cwt but the error says

Input argument "WAV" is undefined.

Error in ==> cwt at 145
if ischar(WAV)

Kindly help me out. Thanks

4. Chich Peng says:

Doubt that the windowed FFT spectrogram of the seismic signal is that bad as shown.

5. Chich Peng says:

The seismic signal is not really that noisy. Can anybody miss the two events simply by eyeball inspection of the time series? What THIS EXAMPLE of wavelet analysis gives is no more than a tiny visual enhancement. It's an overkill.

6. adhithiyan sri says:

Sir In 27th line of ur program,if i use cwt in my program…when i compile it,it showing me a error in command window…how to rectify it….

7. Prabakaran Kesavan says:

Can you please kindly check the time duration of the earthquake signal? It should be in secs, not in mins. Because Earthquake generally lasts from 40 secs to 80 secs, not mins. The obtained frequency is also in mHz!!! It is usually Hz.

8. vamsikrishna srirangam says:

emotionless person :/

9. user73o1u 81716 says:

Should include the inverse cwt to reconstruct the denoised signal. Come on MathWorks. We want more than a quick and dirty teleprompt… Besides that average quality of speaker and video is acceptable.

10. RebeliousSapien says:

fantastic job. thank you so much for this video series.

11. Jayalakshmi Raju says:

Is it necessary that the input must be in discrete time domain? What if i have a signal in the frequency domain? kindly help.

12. Eswari Frd says:

whether I can use the single o/p coefficients for further analysis without using ICWT

13. pukhraj khemada says:

Sir where we find vortex array progrm

14. aboudou aboudou says:

I am tried to use wavelet packet and extract the signal ex :w3.0,…w3.7, i can find only how to plot wptree and get a tools to see every level signals but I cannot find the instruction used to get each signal of level and used it
Could you help me please in this problem
Best regard

15. Abhishek S says:

how to get this code??

16. Shipra Rajput says:

Can we have 3-D representation of the CWT analysis of the signal?