# Continuous wavelet transform implementation using morlet

20 views (last 30 days)
vinod naidu on 10 May 2016
Answered: vinod naidu on 16 May 2016
hi , I wanted to implement Morlet based CWT function Morlet wavlet is my aim is to find the CWT coefficients a,b (scaling, shifting parameters) I have a recorded audio signal has 81410x1 double & sampling rate is 44100
x=audioread('rec2.wav'); a0 = 2^(1/32); scales = a0.^(0.5*32:1*32); % scaling has to be 1.65 to 2 , Is this right way to scaling ? [cfs,sc,frequencies] = cwt(x,scales,'cmor1-1.5',1,'scal');
when i run this code i was getting cfs [13x81410] complex double matrix
So this cfs matrix represents a & b from the 1st equn ? and trying to plot the cfs matrix , how to do that? and Later i want to do squaring of a&b coeff and plot it ? Wayne King on 12 May 2016
Hi Vinod, First, I would recommend using CWTFT as opposed to CWT. The default wavelet for CWTFT is the "analytic" Morlet wavelet which is proportional to the expression you have, it is essentially a complex exponential with a default radian frequency of 6, or cyclical frequency of 6/(2\pi) -- f_0 in your expression.
I'm not sure what your aim is with this analysis but I don't think your scales vector is correct. You are using scales that are much too small to be usable.
CWTFT provides default scales, but if you want, you can specify them. Something that would be a good place to start would be
dt = 1/44100;
s0 = 2*dt;
a0 = 2^(1/10); % 10 voices per octave
scales = s0*a0.^(0:14*10); % 14 octaves
Then you call CWTFT with
cwtx = cwtft({x,dt},'scales',scales);
The output is a structure array with a frequencies field. That field contains the approximate scale to frequency conversion for each row of the matrix, cwtx.cfs.
Each row of the matrix is a value of "a" the scaling parameter. This is the CWT so the translation is fixed at 1. Each row of the matrix is equal to the original signal length.

vinod naidu on 13 May 2016
Edited: vinod naidu on 13 May 2016
well my intention is to find the the peaks of my recorded audio signal when it exceeds certain threshold (0.40) and consider the peak when it happens within the time interval of (100-160m sec)
on the y axis summation of squared frequency components , x-axis time reff,
x=audioread('C:\Users\Vinod Naidu\Documents\Audacity Recordings\rec2.wav'); Fs= numel(x); % number of samples dt = 1/Fs; % sampling period t = 0:dt:1-dt; % Time interval
s0 = 2*dt;
a0 = 2^(1/10); % 10 voices per octave
scales = s0*a0.^(0:14*10); % 14 octaves
cwtx = cwtft({x,dt},'scales',scales);
plot(t*1000,abs(cwtx.cfs(1,:).^2)*1000); % magnitude plot
the output is How to find out the peak has happened at threshold within the time interval ?
I have attached my recorded signal
Wayne King on 13 May 2016
When you say 0.4, are you referring to a value in the original signal units? Because you don't have any value greater than 0.4 in your original data. Or are you simply referring to values in the wavelet domain?
Why are you scaling the magnitude-squared wavelet coefficients by 1000?

vinod naidu on 16 May 2016
well it was my mistake, now i would like to find out my peak when it exceeds the 0.0002 and I would like to know which curve fitting method is suitable for my output cause i wanted to do conform a peak when the start and end points values( +/- 58m sec) form peak values are less then the threshold values