Some bugs(?) in cwt, continuous wavelet transformation function in matlab.

5 views (last 30 days)
Hi, mate.
During for wavelet anaylsis my data. I found strange point in using cwt function in matlab. When I extract [wt, f] variables using this function and plot it, however, it doesn't the same as the plot which used in cwt plot.
Here is an example in mablab, Kobe data. First one is just using that command
load kobe
cwt(kobe,1);
Last one is using that commands
load kobe
[wt,f,coi] = cwt(kobe,1);
imagesc((1:numel(kobe))./60,f*1e3,abs(wt));
set(gca,'Ydir','normal');
xlabel('Time(mins)')
ylabel('Frequency[mHz]')
I think there are some problems in frequency output of this function. Is there any methods to revise that error?
Regards,
Minho

Answers (1)

Wayne King
Wayne King on 7 Oct 2016
Hi Minho, This is because when you call CWT with no output arguments, the CWT uses a logarithmic frequency axis, it actually uses log to the base 2 as explained in the help.
"The frequency or period axis in the scalogram uses a log2 scale."
The wavelet transform most appropriately uses logarithmic scaling on the frequency axis because of the dilation property of the wavelet. So if you use a logarithmic axis
[wt,f,coi] = cwt(kobe,1);
imagesc((1:numel(kobe))./60,log2(f*1e3),abs(wt));
ax = gca;
ytick = str2num(cell2mat(ax.YTickLabel));
ax.YTickLabel = num2str(2.^ytick);
set(gca,'Ydir','normal');
xlabel('Time(mins)')
ylabel('Frequency[mHz]')
You will see it is the same. In your example, you are using a linear frequency axis. That is what accounts for the difference in what you see.

Community Treasure Hunt

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

Start Hunting!