The difference between the old version and new version of CWT (Continuous Wavelet Transform)

9 views (last 30 days)
Hi Everyone!!!
My name is Supatat Hovanotayan. I am a master student studying in Mechanical Engineering, The University of Tokyo.
The reason why I am writing this question is to ask and consult you about the old version and new version of cwt code.
Newer version:
Older version:
However, for my research, I have used old and new version of cwt code both to detect abrupt change in roll angular velocity of rail vehicle.
** I am using MATLAB2019a**
This is roll angular velocity signal as shown below
s.jpg
The figure shown below is the result when I used the old version of cwt
old.jpg
And the result when I used the new version of cwt
new.jpg
According to the results, they are totally diferrent, you can see that the result of the old version of cwt shows the maximum wavelet coefficientn the low frequency range[around 1Hz].
But the result of the new version of cwt showa the maximum wavelet coefficient at the around 10Hz.
It makes me confused with it. First of all, I though the result should be like the old version, but once the used the new version of cwt I got the diffrent result.
Therefore, this is my quesion
  1. What is the diferrece between the old and new version? [I read realease notebook already but do not understand clearly]
  2. Do you think which result is correct?
  3. Why did I get different results?
Could anyone please help me to find out this problem it is very impoetant to my master thesis
Thank you very much for your help in advance
I am looking forward to hearing from you
Best regards,
Supatat Hovanotayan

Accepted Answer

Wayne King
Wayne King on 5 Aug 2019
Hi Supatat, Some of this has been discussed here:
You did not show the code that you used in both cases (old CWT api and new CWT api), but obviously we recommend the new API for a number of reasons.
In your specific case, if you are actually looking at the where the maximum values occur in the wavelet transform, then the old version is not recommend because it normalizes the wavelets using L2 normalization. That is discussed here:
In your case this means that the bandpass filter used has a peak amplitude that depends on the scale, the lower the scale the higher the amplitude. So it biases the results toward larger scales (or lower frequencies). The new CWT does not do that, all filters have the same magnitude in L1 normalization, that is a fairer picture. That is particularly true if you are looking at values. Qualitatively, it looks like the picture of the signal is the same in both othe old and new CWT, but the L2 normalization of the old API is biasing the results toward lower frequencies.
For example: Here we have two oscillations with unambigously unit amplitude. See that the new CWT gets it right.
Fs = 1e3;
t = 0:1/Fs:1;
x = cos(2*pi*32*t).*(t>=0.1 & t<0.3)+sin(2*pi*64*t).*(t>0.7);
cwt(x,1000)
Try the above example with the old CWT and you will see that the reported amplitude (magnitude) for the 32-Hz component is larger than the 64-Hz component and neither of them will be close to 1.
Hope that helps,
Wayne
  1 Comment
Supatat Hovanotayan
Supatat Hovanotayan on 5 Aug 2019
Thank you very much for your reply Mr. Wayne
These are cwt codes I used
old version:
scale = 1:512
Fs = 200;
t = 0:1/Fs:(length(roll)-1)/Fs;
[cfs,freq] = cwt(roll,scale,'morl',1/Fs)
surf(t,freq,abs(cfs));
colormap jet;
shading interp
xlabel('Time(s)'),ylabel('Frequency (Hz)')
new version:
Fs = 200;
t = 0:1/Fs:(length(roll)-1)/Fs;
[coef,f] = cwt(roll,Fs,'amor');
surf(t,f,abs(coef));
colormap jet;
shading interp
xlabel('Time(s)'),ylabel('Frequency (Hz)')
For your answer, it makes me understand it much better. Thank you very much
And I will try the example that you gave me in your answer.
Thank you very much for your help
PS: If I have any question, Can I ask you again?

Sign in to comment.

More Answers (2)

garima
garima on 31 May 2020
Hi Supatat,
since I have just started learning of wavelet transfrom .
could you please explain, how to decide scale for cwt (if we are using older cwt)?
what is the significance of scale.

garima
garima on 31 May 2020
Hello wayne,
I have tried the above example with the old CWT example given by you.
is there any way to scale (correct) the amplitude?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!