www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/FrequencyResponseOfHalfbandDecimatorExample.m

    %% Impulse and Frequency Response of Half-band Decimation Filter
% Create a lowpass half-band decimation filter for data sampled at 44.1
% kHz. The output data rate is 1/2 the input sampling rate, or 22.05 kHz.
% Specify the filter order to be 52 with a transition width of 4.1 kHz.

% Copyright 2015 The MathWorks, Inc.


Fs = 44.1e3; 
filterspec = 'Filter order and transition width';
Order = 52;
TW = 4.1e3; 
firhalfbanddecim =dsp.FIRHalfbandDecimator('Specification',filterspec,...
                                              'FilterOrder',Order,...
                                              'TransitionWidth',TW,...
                                              'SampleRate',Fs);

%%
% Plot the impulse response. The zero-th order coefficient is delayed 26
% samples, which is equal to the group delay of the filter. This yields a
% causal half-band filter.
fvtool(firhalfbanddecim,'Analysis','impulse')
%%
% Plot the magnitude and phase response.
fvtool(firhalfbanddecim,'Analysis','freq')