Digital Signal Processing Reference
In-Depth Information
15.1 can be used by naming the appropriate window function. The syntaxes for
various types of length-
N
window functions are as follows:
>> win coeff
=
rectwin(N); % rectangular window
>> win coeff
=
bartlett(N); % bartlett window
>> win coeff
=
hann(N); % hanning window
>> win coeff
=
hamming(N); % hamming window
>> win coeff
=
blackman(N); % blackman window
For Example 15.2, the M
ATLAB
code for the design of the FIR filter using the
Hamming window is given by
% lowpass filter design using Hamming window
>> wn
=
0.4375; % Normalized cut-off
% frequency
>> N
=
53; % Hamming Window
>> h hamm
=
fir1
(
N-1,wn, 'low',hamming(N));
% Impulse response of
% the LPF
>> w
=
0:0.001*pi:pi; % discrete frequencies
% for response
>> H hamm
=
freqz(h hamm,1,w); % transfer function
>> plot(w,20*log10(abs(H hamm))); % magnitude response
>> axis([0 pi -120 20]); % set axis
>> title('FIR filter using Hamming window')
>> grid on
The magnitude response of the FIR filter obtained with the Hamming window
is shown in Fig. 15.19(a). Note that the magnitude response satisfies the filter
specifications.
The M
ATLAB
code for the design of the FIR filter using the Blackman
window is similar, except for a few minor changes, which are shown below.
% lowpass filter design using Blackman window
>> wn
=
0.4375; % Normalized cut-off
% frequency
>> N
=
88; % Blackman Window size
>> h black
=
fir1(N-1,wn, 'low',blackman(N));
% Impulse response of
% the LPF
>> w
=
0:0.001*pi:pi; % discrete frequencies
% for response
Search WWH ::
Custom Search