www.gusucode.com > wavelet 源码程序 matlab案例代码 > wavelet/PlotCWTWithFrequenciesExample.m

    %% Plot CWT with Frequencies in a Contour Plot
% The example shows how to create a contour plot of the CWT using approximate
% frequencies in Hz. 
%%
% Create a signal consisting of two sine waves with
% disjoint support in additive noise. Assume the signal is sampled at 1
% kHz.
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = 1.5*cos(2*pi*100*t).*(t<0.25)+1.5*cos(2*pi*50*t).*(t>0.5 & t<=0.75);
x = x+0.05*randn(size(t));
%%
% Obtain the CWT of the input signal and plot the result. 
[cfs,f] = cwt(x,Fs);
contour(t,f,abs(cfs).^2); 
axis tight;
grid on;
xlabel('Time');
ylabel('Approximate Frequency (Hz)');
title('CWT with Time vs Frequency');