www.gusucode.com > wavelet 源码程序 matlab案例代码 > wavelet/MODWPTDetailsForTwoSineWavesExample.m
%% MODWPT Details for Two Sine Waves % Obtain the MODWPT details for a signal containing 100 Hz and 450 Hz sine % waves. Each row of the |modwptdetails| output corresponds to a separate % frequency band. dt = 0.001; fs = 1/dt; t = 0:dt:1; x = (sin(2*pi*100*t)+sin(2*pi*450*t)); [lo,hi] = wfilters('fk22'); wptdetails = modwptdetails(x,lo,hi); %% % Use |modwpt| to obtain the energy and center frequencies of the signal. % Plot the energy in the wavelet packets. The fourth and fifteenth % frequency bands contain most of the energy. Other frequency bands have % significantly less energy. The frequency ranges of fourth and fifteenth % bands are approximately 94-125 Hz and 438-469 Hz, respectively. [wpt,~,cfreqs,energy] = modwpt(x,lo,hi); figure bar(1:16,energy); xlabel('Packet') ylabel('Packet Energy') title('Energy by Wavelet Packet') %% % Plot the power spectral density of the input signal. pwelch(x,[],[],[],fs,'onesided'); title('Power Spectral Density of Input Signal') %% % Show that the MODWPT details have zero-phase shift from the 100 Hz input % sine. p4 = wptdetails(4,:); plot(t,sin(2*pi*100*t).*(t>0.3 & t<0.7)) hold on plot(t,p4.*(t>0.3 & t<0.7),'r') legend('Sine Wave','MODWPT Details')