thiet ke loc so

of 30 /30
Chapter 8 IIR Filter Design 1. Problem P 8.1 Analog Butterworth lowpass lter design: p = 30 rad/s, R p = 1 dB, s = 40 rad/s, As = 30 dB. M ATLAB Script: clear, close all; % Filter Specifications Wp = 30; Ws = 40; Rp = 1; As = 30; % Filter Design [b,a] = afd_butt(Wp,Ws,Rp,As); format short e *** Butterworth Filter Order = 15 % Cascade Structure [C,B,A] = sdir2cas(b,a) C = 2.8199e+022 B = 001 A = 1.0000e+000 6.1393e+001 9.8484e+002 1.0000e+000 5.7338e+001 9.8484e+002 1.0000e+000 5.0777e+001 9.8484e+002 1.0000e+000 4.1997e+001 9.8484e+002 1.0000e+000 3.1382e+001 9.8484e+002 1.0000e+000 1.9395e+001 9.8484e+002 1.0000e+000 6.5606e+000 9.8484e+002 0 1.0000e+000 3.1382e+001 % Frequency Response Wmax = 100; [db,mag,pha,w] = freqs_m(b,a,Wmax); pha = unwrap(pha); % Impulse Response %The impulse response of the designed filter when computed by Matlab is numerically %unstable due to large coefficient values. Hence we compute the impulse response %of the filter with Wp/10 and Ws/10 band edges to keep coefficient values small. %The actual impulse response is time-scaled and amplitude scaled version of the %computed impulse response. [b,a] = afd_butt(Wp/10,Ws/10,Rp,As); [ha,x,t] = impulse(b,a); *** Butterworth Filter Order = 15 t = t/10; ha = ha/10; % 111

Embed Size (px)

description

solution

Transcript of thiet ke loc so

Chapter 8

IIR Filter Design1. Problem P 8.1 Analog Butterworth lowpass lter design: M ATLAB Script: 111p = 30

rad/s, R

p=1

dB, s = 40 rad/s, As = 30 dB.

112 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

The system function is given by Ha (s) = 2:8199

1022 1122 s + 57:338s + 984:84 s + 50:777s + 984:84 11 2 + 41:997s + 984:842 + 31:382s + 984:84ss 11 s2 + 19:395s + 984:84s2 + 6:5606s + 984:84 1 s2 + 61:393s + 984:84

1 s + 31:382 The lter design plots are given in Figure 8.1. 2. Problem P 8.2 Analog Elliptic lowpass lter design: p = 10 rad/s, R M ATLAB Script:

p=1

dB, s = 15 rad/s, As = 40 dB.

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

113 Analog Butterworth Lowpass Filter Design Plots in P 8.1Magnitude Response0 1 0.89 Magnitude 30 Decibels

LogMagnitude Response0 0 30 40 Analog frequency in rad/sec 100 100 0 30 40 Analog frequency in rad/sec 100

Phase Response0 0.1

Impulse Response

Phase in pi units 0.05 3.47 4.89 ha(t) 0 0 30 40 Analog frequency in rad/sec 100 0.05 0 0.5 1 t (sec) 1.5 2

Figure 8.1: Analog Butterworth Lowpass Filter Plots in Problem P 8.1

114 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

The system function is given by Ha (s) = 46978s4 + 220:07s2 + 2298:5 s5 + 9:23s4 + 184:71s3 + 1129:2s2 + 7881:3s + 22985:

The lter design plots are given in Figure 8.2. Analog Elliptic Lowpass Filter Design Plots in P 8.2Magnitude Response1 0.89 logMagnitude in dB Magnitude 0 40 0 0

LogMagnitude Response

1015 Analog frequency in rad/sec 30 100 0 1015 Analog frequency in rad/sec 30

Phase Response0 3 2 ha(t) 1.26 1.64 1 0 1 2

Impulse Response

Phase in pi units 0 1015 Analog frequency in rad/sec 30 0 2 4 t (sec) 6 8 10

Figure 8.2: Analog Elliptic Lowpass Filter Design Plots in P 8.2 3. Problem P 8.3

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

115 The lter passband must include the 100 Hz component while the stopband must include the 130 Hz component. To obtain a minimum-order lter, the transition band must be as large as possible. This means that the passaband cutoff must be at 100 Hz while the stopband cutoff must be at 130 Hz. Hence the analog Chebyshev-I lowpass lter specications are: p = 2 (100) rad/s, R p = 2 dB, s = 2 (130) rad/s, As = 50 dB. M ATLAB Script:

116 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

The system function is given by Ha (s) = 7:7954 1022

1 1 s2 + 142:45s + 51926 s2 + 75:794s + 301830 The magnitude response plots are given in Figure 8.3. 1 s2 + 116:12s + 168860 11 2 + 26:323s + 388620ss + 75:794

Analog ChebyshevI Lowpass Filter Design Plots in P 8.3Magnitude Response1 0.79 Magnitude 0 0 100130 Analog frequency in Hz 200

LogMagnitude Response0 Decibels 50 100 0 100130 Analog frequency in Hz 200

Figure 8.3: Analog Chebyshev-I Lowpass Filter Plots in Problem P 8.3 4. Problem P 8.4 Analog Chebyshev-II lowpass lter design: p = 2 (250) rad/s, R p = 0:5 dB, s = 2 (300) rad/s, As = 45 dB. M ATLAB Script:

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

117

118 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

The lter design plots are given in Figure 8.4. Digital Butterworth Filter Design Plots in P 8.7LogMagnitude Response0 Decibel 50 0 0.4 Frequency in Hz 0.6 1

Impulse Response0.1 ha(t) 0 0.1 0 10 20 30 40 5060 time in seconds 70 80 90 100

Figure 8.4: Analog Chebyshev-II Lowpass Filter Plots in Problem P 8.4 5. Problem P 8.5 M ATLAB function ad f . 6. Problem P 8.6

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

119 Digital Chebyshev-1 Lowpass Filter Design using Impulse Invariance. M ATLAB script: (a) Part (a): T = 1. M ATLAB script: The lter design plots are shown in Figure 8.5. (b) Part (b): T = 1=8000. M ATLAB script:

120 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

Filter Design Plots in P 8.6aLogMagnitude Response0 Decibel 40 60 0 1500 2000 Frequency in Hz 4000 0.3 0.2 0.1 0 0.1 0.2 h(n) 0 10 20 30 40 50 n 60 70 80 90 100

Impulse Response

Figure 8.5: Impulse Invariance Design Method with T =1 in Problem P 8.6a The lter design plots are shown in Figure 8.6. (c) Comparison: The designed system function as well as the impulse response in part 6b are similar to those in part 6a except for an overall gain due to Fs = 1=T = 8000. This problem can be avoided if in the impulse invariance design method we set h (n) = T ha (nT ) 7. Problem P 8.7 Digital Butterworth Lowpass Filter Design using Impulse Invariance. MATLAB script:

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

121 Filter Design Plots in P 8.6bLogMagnitude Response 0 Decibel 40 60 0 15002000 Frequency in Hz Impulse Response 40003000 2000 1000 0 1000 2000 h(n) 0 10 20 30 40 50 n 60 70 80 90 100

Figure 8.6: Impulse Invariance Design Method with T = 1=8000 in Problem P 8.6b The lter design plots are shown in Figure 8.7. Comparison: From Figure 8.7 we observe that the impulse response h (n) of the digital lter is a sampled version of the impulse response ha (t ) of the analog proptotype lter as expected.

122 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

Digital Butterworth Filter Design Plots in P 8.7LogMagnitude Response0 Decibel 50 0 0.4 Frequency in Hz 0.6 1

Impulse Response0.1 ha(t) 0 0.1 0 10 20 30 40 5060 time in seconds 70 80 90 100

Figure 8.7: Impulse Invariance Design Method with T =2 in Problem P 8.7 8. M ATLAB function d l

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

123 M ATLAB verication using Problem P8.7:

124 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

The lter design plots are given in Figure 8.8. Digital Butterworth Filter Design Plots in P 8.8LogMagnitude Response0 Decibel 50 0 0.40.6 Frequency in pi units 1 0.5 |H| 0.0 0 0.40.6 Frequency in pi units 1

Magnitude Response

Figure 8.8: Digital lter design plots in Problem P8.8. 9. Problem P 8.11 Digital Butterworth Lowpass Filter Design using Bilinear transformation. M ATLAB script: (a) Part(a): T = 2. M ATLAB script:

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

125 The lter design plots are shown in Figure 8.9. Comparison: If we compare lter orders from two methods then bilinear transformation gives the lower order than the impulse invariance method. This implies that the bilinear transformation design method is a better one in all aspects. If we compare the impulse responses then we observe from Figure 8.9 that the digital impulse response is not a sampled version of the analog impulse response as was the case in Figure 8.7. (b) Part (b): Use of the bt function. M ATLAB script: u t

126 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

Digital Butterworth Filter Design Plots in P 8.11aLogMagnitude Response0 Decibel 50 0 0.4 Frequency in Hz 0.6 1

Impulse Response0.2 ha(t) 0 0.2 0 10 20 30 40 5060 time in seconds 70 80 90 100

Figure 8.9: Bilinear Transformation Design Method with T =2 in Problem P 8.11a The lter design plots are shown in Figure 8.10. Comparison: If we compare the plots of lter responses in part 9a with those in part 9b, then we observe that the function satises stopband specications exactly at s . Otherwise the both designs are essentially similar. bt u t r e 10. Problem P 8.13 Digital Chebyshev-1 Lowpass Filter Design using Bilinear transformation. M ATLAB script:

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

127 Digital Butterworth Filter Design Plots in P 8.11bLogMagnitude Response0 Decibel 50 0 0.4 Frequency in Hz 0.6 1

Impulse Response0.2 h(n) 0 0.2 0 5 10 15 20 25 n 30 35 40 45 50

Figure 8.10: Butterworth lter design using the bt function in Problem P 8.11b u t = 1. (a) Part(a): T M ATLAB script: (b) Part(b): T = 1=8000. The lter design plots are shown in Figure 8.11. M ATLAB script:

128 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

Filter Design Plots in P 8.13aLogMagnitude Response0 Decibel 40 60 0 1500 2000 Frequency in Hz 4000 0.3 0.2 0.1 0 0.1 0.2 h(n) 0 10 20 30 40 50 n 60 70 80 90 100

Impulse Response

Figure 8.11: Bilinear Transformation Design Method with T =1 in Problem P 8.13a The lter design plots are shown in Figure 8.12. (c) Comparison: If we compare the designed system function as well as the plots of system responses in part 10a and in part 10a, then we observe that these are exactly same. If we compare the impulse invariance design in Problem 6 with this one then we note that the order of the impulse invariance designed lter is one higher. This implies that the bilinear transformation design method is a better one in all aspects. 11. Digital lowpass lter design using elliptic prototype. M ATLAB script using the b function: i

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

129 Filter Design Plots in P 8.13bLogMagnitude Response0 Decibel 40 60 0 1500 2000 Frequency in Hz 4000 0.3 0.2 0.1 0 0.1 0.2 h(n) 0 10 20 30 40 50 n 60 70 80 90 100

Impulse Response

Figure 8.12: Bilinear Transformation Design Method with T = 1=8000 in Problem P 8.13b

130 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

The lter design plots are shown in Figure 8.13. Digital Elliptic Filter Design Plots in P 8.14aLogMagnitude Response0 Decibel 60 80 0 0.4 Frequency in Hz 0.6 1 0.2 ha(t) 0 0.2 0 10 20 30 40 5060 time in seconds 70 80 90 100

Impulse Response

Figure 8.13: Digital elliptic lowpass lter design using the bilinear function in Problem P8.14a. M ATLAB script using the el function: l i

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

131 The lter design plots are shown in Figure 8.14. From these two gures we observe that both functions give the same design in which the digital lter impulse response is not a sampled version of the corresponding analog lter impulse response. Digital Elliptic Filter Design Plots in P 8.14bLogMagnitude Response0 Decibel 60 80 0 0.4 Frequency in Hz 0.6 1 0.2 h(n) 0 0.2 0 5 10 15 20 25 n 30 35 40 45 50

Impulse Response

Figure 8.14: Digital elliptic lowpass lter design using the ellip function in Problem P8.14b. 12. Digital elliptic highpass lter design using bilinear mapping. M ATLAB function d h

132 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

(a) Design using the d function: bl h

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

133 The lter frequency response plot is shown in the top row of Figure 8.15. (b) Design using the el function: l i The lter frequency response plot is shown in the bottom row of Figure 8.15. Both M ATLAB scripts and the Figure 8.15 indicate that we designed essentially the same lter. 13. Digital Chebyshev-2 bandpass lter design using bilinear transformation. M ATLAB script:

134 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB A PRIL 98

Digital Elliptic Filter Design Plots in P 8.17Design using the dhpfd_bl function0 Decibel 60 80 0 0.4 Frequency in Hz 0.6 1 0 Decibel 60 80 0 0.4 Frequency in Hz 0.6 1

Design using the ellip function

Figure 8.15: Digital elliptic highpass lter design plots in Problem 8.17. The lter impulse and log-magnitude response plots are shown in Figure 8.16.

A PRIL 98 S OLUTIONS M ANUALFOR

DSPUSING M ATLAB

135 Digital Chebyshev2 Bandpass Filter Design Plots in P 8.19Impulse Response0.15 0.1 0.05 h(n) 0 0.05 0.1 0 5 10 15 20 25 n 30 35 40 45 50

LogMagnitude Response0 Decibel 50 70 0 0.3 0.40.50.6 Frequency in pi units 1

Figure 8.16: Digital Chebyshev-2 bandpass lter design plots in Problem P8.19.