Digital Signal Processing Reference
In-Depth Information
optimal F IR filte r
FIR filter using Kaiser window
20
20
0
0
−20
−20
−40
−40
−60
−60
−80
−80
−100
−100
−120
−120
0
0.5
1
1.5
2
2.5
3
0
0.5
1
1.5
2
2.5
3
(a)
(b)
The M ATLAB code for the design of the optimal FIR filter is similar to the
M ATLAB code in Example 15.8, except for the use of the firpm function,
which replaces the fir1 function:
Fig. 15.21. Optimal FIR filter
designed in Example 15.11 using
M ATLAB . (a) Optimal FIR filter of
length N
= 47. (b) FIR filter of
length N
= 47 using the Kaiser
% optimal lowpass filter design using Parks-McClellan
% algorithm
>> sz = 47; % Length of FIR filter
>> range norm cut off = [0, 0.375, 0.5, 1];
% normalized cut-off
% frequencies
>> f response = [1, 1, 0, 0]; % gains at the cut-off
% frequencies
>> wmatrix = [0.0032/0.0562, 1]; % weight matrix
>> h optimal = firpm(sz-1, range norm cut off,f response,
wmatrix); % Impulse response of
% the optimal LPF
% FIR filter
>> w = 0:0.001*pi:pi; % discrete frequencies
>> H optimal = freqz(h optimal,1,w);% transfer function
>> plot(w,20*log10(abs(H optimal)));% magnitude response
>> axis([0 pi -120 20]);
window.
% set axis
>> title('optimal FIR filter');
>> grid on
The magnitude response of the optimal FIR filter obtained from the above code
is shown in Fig. 15.21(a). Comparing Fig. 15.21(a) with the magnitude response
of the FIR filter obtained from the Kaiser window shown in Fig. 15.21(b), the
following differences are noted.
Search WWH ::




Custom Search