Digital Signal Processing Reference
In-Depth Information
Table 7.11
Illustrative Usage for MATLAB Function
firfs(N, Hk)
function B
¼
firfs(N,Hk)
%B
firls(N,Hk)
% FIR filter design using the frequency sampling method.
% Input parameters:
% N: the number of filter coefficients.
% note: N must be odd number.
% Hk: sampled frequency response for k
¼
¼
0,1,2,
,M
¼
(N-1)/2.
.
% Output:
% B: FIR filter coefficients.
(number of taps) and a vector
Hk
containing the specified magnitude values H
k
, k ¼ 0; 1;
/
; M. Finally, the
MATLAB function will return the calculated FIR filter coefficients.
EXAMPLE 7.13
a.
Design a linear phase lowpass FIR filter with 25 coefficients using the frequency sampling method. Let the
cutoff frequency be 2,000 Hz and assume a sampling frequency of 8,000 Hz.
b.
Plot the frequency responses.
c.
List the FIR filter coefficients.
Solution:
a. The normalized cutoff frequency for the lowpass filter is U
c
¼ uT ¼ 2p2000=8000 ¼ 0:5p radi-
ans, N ¼ 2M þ 1 ¼ 25, and the specified values of the sampled frequency response are chosen to be
H
k
¼½1111111000000
MATLAB Program 7.8 produces the design results.
Program 7.8. MATLAB program for Example 7.13.
%
Figure 7.31
(Example 7.13)
% MATLAB program to create
Figure 7.31
fs
¼
8000; % Sampling frequency
H1
[1 1 1 1 1 1 1 0 0 0 0 0 0]; % Magnitude specifications
B1
¼
firfs(25,H1); % Design filter
[h1,f]
¼
freqz(B1,1,512,fs); % Calculate magnitude frequency response
H2
¼
[1 1 1 1 1 1 1 0.5 0 0 0 0 0]; % Magnitude specifications
B2
¼
firfs(25,H2);
¼
% Frequency response
[h2,f]
¼
freqz(B2,1,512,fs);
% Calculate magnitude frequency response
p1
¼
180*unwrap(angle(h1))/pi;
p2
¼
180*unwrap(angle(h2))/pi
subplot(2,1,1); plot(f,20*log10(abs(h1)),
'
-.
'
,f,20*log10(abs(h2)));grid
axis([0 fs/2 -80 10]);
xlabel(
'
Frequency (Hz)
'
); ylabel(
'
Magnitude Response (dB)
'
);
subplot(2,1,2); plot(f,p1,
'
-.
'
,f,p2);grid
xlabel(
'
Frequency (Hz)
'
); ylabel(
'
Phase (degrees)
'
);
Search WWH ::
Custom Search