MATLAB: Determining periods using Continuous Wavelet Transform

signal processingWavelet Toolbox

Hi, I have a signal which contains some quasi-periodic patterns which I would like to determine.
As its spectral content changes with time, I think that Wavelet analysis is the method which best fits to my purpose. So that, I was wondering if there exists a canonical way to detect reasonable periods in this signal by looking to CWT coefficients.

Best Answer

Hi Richard, you can use the approximate relationship between scale and frequency to do this.
Create a signal to illustrate this:
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = zeros(size(t));
x([625,750]) = 2.5;
x = x+ cos(2*pi*100*t).*(t<0.25)+cos(2*pi*50*t).*(t>=0.5)+0.15*randn(size(t));
plot(t,x);
Set up the scale vector and spacing:
ds = 0.15;
J = fix((1/ds)*log2(length(x)/8));
dt = 1/Fs;
scales = 2*dt*2.^((0:J).*ds);
Obtain the CWT and plot the response:
cwtstruct = cwtft({x,0.001},'Scales',scales,'Wavelet','morl');
periods = cwtstruct.scales.*(4*pi)/(6+sqrt(38));
freq = 1./periods;
cfs = cwtstruct.cfs;
contour(t,freq,abs(cfs));
set(gca,'xtick',[0 0.25 0.4 0.5 0.6 0.75 1]); grid on;
xlabel('Time (seconds)'); ylabel('Hz');