www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/FilterSquareWaveUsingDyadicFilterBanksExample.m
%% Filter Square Wave Using Dyadic Filter Banks %% % *Note*: This example runs only in R2016b or later. If you are using an % earlier release, replace each call to the function with the equivalent % |step| syntax. For example, myObject(x) becomes step(myObject,x). %% % Denoise square wave input using dyadic analysis and synthesis filter % banks. t = 0:.0001:.0511; x= square(2*pi*30*t); xn = x' + 0.08*randn(length(x),1); hdydanl = dsp.DyadicAnalysisFilterBank; %% % The filter coefficients correspond to a |haar| wavelet. hdydanl.CustomLowpassFilter = [1/sqrt(2) 1/sqrt(2)]; hdydanl.CustomHighpassFilter = [-1/sqrt(2) 1/sqrt(2)]; hdydsyn = dsp.DyadicSynthesisFilterBank; hdydsyn.CustomLowpassFilter = [1/sqrt(2) 1/sqrt(2)]; hdydsyn.CustomHighpassFilter = [1/sqrt(2) -1/sqrt(2)]; C = hdydanl(xn); %% % Subband outputs. C1 = C(1:256); C2 = C(257:384); C3 = C(385:512); %% % Set higher frequency coefficients to zero % to remove the noise. x_den = hdydsyn([zeros(length(C1),1);... zeros(length(C2),1);C3]); %% % Plot the original and denoised signals. subplot(2,1,1), plot(xn); title('Original noisy Signal'); subplot(2,1,2), plot(x_den); title('Denoised Signal');