www.gusucode.com > wavelet 源码程序 matlab案例代码 > wavelet/TimeAlignedMODWPTExample.m
%% Time-Aligned MODWPT % Obtain the time-aligned MODWPT of two intermittent sine waves in noise. % The sine wave frequencies are 150 Hz and 200 Hz. The data is sampled at % 1000 Hz. dt = 0.001; t = 0:dt:1-dt; x = cos(2*pi*150*t).*(t>=0.2 & t<0.4)+ sin(2*pi*200*t).*(t>0.6 & t<0.9); y = x+0.05*randn(size(t)); [wpta,~,Falign] = modwpt(x,'TimeAlign',true); [wptn,~,Fnon] = modwpt(x); %% % Compare the nonaligned and time-aligned time-frequency plots. subplot(2,1,1); contour(t,Fnon.*(1/dt),abs(wptn).^2); grid on; ylabel('Hz'); title('Time-Frequency Plot (Nonaligned)'); subplot(2,1,2) contour(t,Falign.*(1/dt),abs(wpta).^2); grid on; xlabel('Time'); ylabel('Hz'); title('Time-Frequency Plot (Aligned)');