Digital Signal Processing Reference
In-Depth Information
“WnL” and “WnH” are the lower and upper cutoff frequency inputs, respectively. Note that WnH ¼ 0 when
specifying WnL for the lowpass filter design, while WnL ¼ 0 when specifying WnH for the highpass filter design.
“Wtype” specifies the window data sequence to be used in the design, that is, input “1” for the rectangular
window, input “2” for the triangular window, input “3” for the Hanning window, input “4” for the Hamming
window, and input “5” for the Blackman window.
b. The following program (Program 7.2) is used to generate FIR filter coefficients using the rectangular window. Its
frequency responses will be plotted together with the results of the FIR filter design obtained using the Hamming
window, as shown in Program 7.3.
Program 7.2. MATLAB program for Example 7.7.
% Example 7.7
% MATLAB program to generate FIR coefficients
% using the rectangular window.
%
N ¼ 25; Ftype ¼ 1; WnL ¼ 0.5*pi; WnH ¼ 0; Wtype ¼ 1;
B
firwd(N,Ftype,WnL,WnH,Wtype);
Program 7.3. MATLAB program for Example 7.7.
% Figure 7.12
% MATLAB program to create Figure 7.12
%
N
¼
¼
25; Ftype
¼
1; WnL
¼
0.5*pi; WnH
¼
0; Wtype
¼
1;fs
¼
8000;
%design using the rectangular window;
Brec ¼ firwd(N,Ftype,WnL,WnH,Wtype);
N ¼ 25; Ftype ¼ 1; WnL ¼ 0.5*pi; WnH ¼ 0; Wtype ¼ 4;
%design using the Hamming window;
Bham ¼ firwd(N,Ftype,WnL,WnH,Wtype);
[hrec,f] ¼ freqz(Brec,1,512,fs);
[hham,f] ¼ freqz(Bham,1,512,fs);
prec ¼ 180*unwrap(angle(hrec))/pi;
pham ¼ 180*unwrap(angle(hham))/pi;
subplot(2,1,1);
Table 7.6 FIR Filter Coefficients in Example 7.7 (rectangular and Hamming windows)
B: FIR Filter Coefficients (Rectangular
Window)
Bham: FIR Filter Coefficients (Hamming
Window)
b 0 ¼ b 24 ¼
0.000000
b 1 ¼ b 23 ¼
b 0 ¼ b 24 ¼
0.000000
b 1 ¼ b 23 ¼
0.028937
0.002769
b 2 ¼ b 22 ¼
0.000000
b 2 ¼ b 22 ¼
0.000000
b
¼ b
¼
0.035368
b
¼ b
¼
0.007595
3
21
3
21
b
¼ b
¼
0.000000
b
¼ b
¼
0.000000
4
20
4
20
b
¼ b
¼
0.045473
b
¼ b
¼
0.019142
5
19
5
19
b
¼ b
¼
0.000000
b
¼ b
¼
0.000000
6
18
6
18
b
0.063662
b 8 ¼ b 16 ¼ 0.000000
b 9 ¼ b 15 ¼ -0.106103
b 10 ¼ b 14 ¼ 0.000000
b 11 ¼ b 13 ¼ 0.318310
b 12 ¼ 0.500000
¼ b
¼
b
0.041957
b 8 ¼ b 16 ¼ 0.000000
b 9 ¼ b 15 ¼0.091808
b 10 ¼ b 14 ¼ 0.000000
b 11 ¼ b 13 ¼ 0.313321
b 12 ¼ 0.500000
¼ b
¼
7
17
7
17
 
 
Search WWH ::




Custom Search