Professional Documents
Culture Documents
IIR Filters
al y n l = bk x n k
l=0
(8.1)
k=0
al y n l + bk x n k
l=1
(8.2)
k=0
81
Time-Domain Response
Block Diagram
As a special case consider N = M = 3
yn =
l=1
k=0
al y n l + bk x n k
xn
yn
z
b0
xn 1
z
yn 1
1
a1
b1
xn 2
z
yn 2
1
a2
b2
xn 3
yn 3
Feed-forward
b3
part
a3
Feedback
part
Time-Domain Response
To get started with IIR time-domain analysis we will consider
a first-order filter ( N = 1 ) with M = 0
82
Time-Domain Response
y n = a1 y n 1 + b0 x n
(8.3)
y 0 = a1 y 1 + b0 0 = b0
0
y 1 = a1 y 0 + b0 1 = a1 b0
0
y 2 = a1 y 1 + b0 2 = a1 b0
y n = a 1 b 0 n 0
In summary we have shown that the impulse response of a
1st-order IIR filter is
n
h n = b0 a1 u n
(8.4)
83
Time-Domain Response
h n = 0.8 u n
FirstOrder IIR a1 0.8, b0 1
hn
1
0.8
0.6
0.4
0.2
5
10
15
20
N2
x k n k
(8.5)
k = N1
84
Time-Domain Response
yn =
N2
x k h n k
k = N1
N2
(8.6)
x k b0 a1
nk
un k
k = N1
n2
u n 2 0.5
n4
un 4
2
1.5
1
0.5
5
10
15
20
0.5
(8.7)
(8.8)
85
Time-Domain Response
h n = b0 a1 u n + b1 a1
= b0 n + b0 +
n1
un 1
n
1
b1 a1 a1 u n
(8.9)
y 0 = a1 y 1 + b0 u 0 = b0
y 1 = a1 y 0 + b0 u 1 = a1 b0 + b0
y 2 = a1 y 1 + b0 u 2 = a1 a1 b0 + b0 + b0
n
y n = b0 1 + a1 + + a1 = b0
a1
k=0
L+1
1
k
-, r 1
r = -------------------1r
k=0
r=1
L + 1,
L
(8.10)
86
Time-Domain Response
1 a1
y n = b 0 --------------------- u n
1 a1
(8.11)
2. When a 1 1 the a 1
1 0.6
y n = ------------------------------- u n
1 0.6
87
Time-Domain Response
yn
2.5
2
1.5
1
0.5
5
10
15
20
(8.4)
u k b0 a1
nk
un k
(8.5)
k =
n0
n
k
uk
k
0
88
The result is
n
n k
yn =
b0 a1
un
k = 0
= b0 a1
n n
a1
(8.6)
k=0
n+1
n 1 1 a1
= b 0 a 1 -----------------------------------1 1 a1
n+1
1 a1
= b 0 ----------------------------1 a1
which is the same result obtained by the direct recursion
y n = x n * h n X z H z = Y z
For the case of IIR filters H z will be a fully rational function, meaning in general both poles and zeros (more than at
z = 0)
Begin by z-transforming both sides of the general IIR difference equation using the delay property
ECE 2610 Signals and Systems
89
Yz =
al z Y z +
l=1
ZT x n k
M
ZT y n l
bk z X z
k=0
(8.7)
bk z
k
1
b0 + b1 z + + bM z
k=0
H z = ------------------------------ = -----------------------------------------------------------1
N
N
l
1 a1 z aN z
1
al z
(8.8)
l=1
(8.9)
810
b0 + b1 z
H z = -----------------------1
1 a1 z
(8.10)
n = 0:20;
x = [1 zeros(1,20)]; % impulse sequence input
y = filter([-3,2],[1 -0.5],x);
stem(n,y,'filled')
axis([0 10 -3.1 .6])
grid
ylabel('Impulse Response h[n]')
xlabel('Time Index (n)')
0.5
0
0.5
1
1.5
2
2.5
3
0
4
5
6
Time Index (n)
10
811
1+z
H z = -----------------------1
1 0.8z
The impulse response using page 85, eqns (8.7)(8.9)
1
h n = n + 1 + 0.8 0.8 u n 1
The difference equation is
y n = 0.8y n 1 + x n + x n 1
System Functions and Block-Diagram Structures
We have already examined the Direct-Form I structure (p. 8
2)
The Direct-Form I structure implements the feed-forward
terms first followed by the feedback terms
We can view this as a cascade of two systems, which due to
linearity can also be written as
1
1
H z = B z ----------- = ----------- B z
Az
Az
(8.11)
812
xn
wn
1
yn
b0
wn 1
a1
b1
wn 2
a2
b2
wn 3
Az
Combine common
delay blocks
a3
Shown for N = M = 3
wn
xn
a1
a2
a3
b3
Bz
yn
b0
b1
b2
b3
Direct-Form II
813
yn
b0
The MATLAB
function filter()
implements this
block diagram
b1
b2
b3
a1
a2
a3
Transposed Direct-Form II
814
hn = a un
From the definition of the z-transform,
Hz =
n n
a z
1 n
az
(8.12)
n=0
n=0
n=0
n
1
r = ----------- r 1
1r
1 az = ----------------- z a
1
1 az
n=0
1 n
(8.13)
815
ship
z
n
1 a u n -----------------1
1 az
(8.14)
h n = b0 a1 u n + b1 a1
n1
un 1
(8.15)
b0 + b1 z
= ------------------------1
1 a1 z
We will learn later that we can work this operation in reverse,
and when combined with partial fraction expansion, we will
be able to find the inverse z-transform of almost any rational
Hz
b0 + b1 z
z + b1 b0
b0 z + b1
z
- - = -------------------- = b 0 ----------------------H z = -----------------------1 z
z a1
z a1
1 a1 z
ECE 2610 Signals and Systems
816
b1
--------b0
a1
2z
2
H z = ----------------------- = --------------1
z 0.8
1 0.8z
This system has a pole at z = 0.8 and zero at z = since
lim H z = 0
z
817
Example: Pole at z =
Consider
1
1 + 0.5z
H z = ------------------------ = z + 0.5
1
z
This system has a pole at z = and a zero at z = 0.5
Pole Locations and Stability
We know that
n
1 z
h n = a u n -----------------= Hz
1
1 az
(8.16)
Example: H z = 1 5z 1 0.995z
Converting to positive powers of z
z 5 Pole at z = 0.995 so stable
H z = --------------------z 0.995
818
Example: Second-order H z
Suppose that
1
z z + 0.2
1 + 0.2z
H z = ------------------------------------------------ = -------------------------------------1
2
2
1 1.4z + 0.81z
z 1.4z + 0.81
z z + 0.2
= ------------------------------------------------------------------------------------------------ z 0.7 + j0.4 2 z 0.7 j0.4 2
j0.680
Imaginary Part
0.4
0.2
0
0.2
0.4
0.6
0.8
1
1
0.5
0
Real Part
0.5
819
j
found by letting z e in the system function (provided the
system is stable)
He = Hz
z=e
(8.17)
+ 0.81z
we have
1 + 0.2e
H e = --------------------------------------------------------
j
j 2
1 1.4e + 0.81e
|H(ej)|
10
Bandpass
Filter
5
0
hat()
0.680
H(ej)
2
0
2
820
This particular filter is a bandpass filter because it has a relative large magnitude response over a narrow band of frequencies and small response otherwise
From the earlier pole-zero analysis, the peak gain is near the
angle the poles make to the real axis, 0 = 0.680
1
Example: H z = 1 1 0.8z
Here we have
j
1
H e = -------------------------
j
1 0.8e
Plotting using freqz() we have
>> w = -pi:(pi/500):pi;
>> H = freqz(1,[1 -0.8],w);
|H(ej)|
Lowpass
Filter
4
2
0
0
hat()
H(ej)
2
0
2
821
Example: H z = 1 1 + 0.8z
Here we have
j
1
H e = -------------------------
j
1 + 0.8e
Plotting using freqz() we have
>> w = -pi:(pi/500):pi;
>> H = freqz(1,[1 0.8],w);
|H(ej)|
Highpass
Filter
4
2
0
0
hat()
H(ej)
2
0
2
822
3D Surface Plot of H z
Consider the second-order system
1
1 + 0.2z
H z = -----------------------------------------------1
2
1 1.4z + 0.81z
A 3D surface plot of H z can help clarify how the frequency response is obtained by evaluating H z around the
unit circle
conjugte poles
Unit circle
Second-Order,
Bandpass
H(z)
zeros at
z = 0 and
z = -0.2
2
1
Im
1
0
0
1
2
2
1
1
Re
823
X z
1.
ax 1 n + bx 2 n
aX 1 z + bX 2 z
2.
x n n0
3. y n = x n * h n
n0
Xz
Y z = H z X z
4.
5.
n n0
6.
a un
z
z
n0
1 -----------------1
1 az
824
Ak
--------------------1
k = 1 1 pk z
where A k = H z 1 p k z
z = pk
Ak pk u n
k=1
1 + 2z
H z = ------------------------------------3 1 1 2
1 --- z + --- z
8
4
First we factor the denominator
3 4 9 16 1 2 = 3--- 1--p 1 2 = --------------------------------------------------8 8
21
825
1
A1
A2
1
+
2z
H z = --------------------------------------------------- = ------------------- + ------------------1
1
1
1 1--- z 1 1 1--- z 1
1 --- z
1 --- z
2
4
4
2
Solving for A 1
1
1 + 2z
1 1
A 1 = --------------------------------------------------- 1 --- z
2
1 1--- z 1 1 1--- z 1
4
2
1
+ 2z = 1------------------1 1
1 --- z
4
=2
z = 12
+ 4- = 10
= 1----------1 1--2
Solving for A 2
1
1 + 2z
1 1
A 2 = --------------------------------------------------- 1 --- z
4
1 1--- z 1 1 1--- z 1
4
2
1
1 + 2z
= ------------------1 1
1 --- z
2
z = 14
+ 8- = 9
= 1----------12
z
=4
So,
10
9 H z = ------------------- ------------------1 1
1 1
1 --- z
1 --- z
2
4
Inverse z-transform term-by-term using #6
ECE 2610 Signals and Systems
826
1 n
1 n
h n = 10 --- u n 9 --- u n
2
4
The MATLAB signal processing toolbox has a function that
can perform partial fraction expansion
>> help residuez
RESIDUEZ Z-transform partial-fraction expansion.
[R,P,K] = RESIDUEZ(B,A) finds the residues, poles and direct terms
of the partial-fraction expansion of B(z)/A(z),
B(z)
r(1)
---- = ------------ +...
A(z)
1-p(1)z^(-1)
r(n)
------------ + k(1) + k(2)z^(-1) ...
1-p(n)z^(-1)
%
%
%
%
%
%
827
3
2
1
0
10
12
14
16
18
20
8
10
12
Time Index (n)
14
16
18
20
They agree!
3
2
1
0
828
Example: y n = x n * h n
Find y n for an IIR system having input x n = 2u n and
system function
1
1+z
H z = ------------------------------------1 1 1 2
1 --- z --- z
6
6
We will first find Y z
From table entry #6 with a = 1
2
X z = ---------------1
1z
As a result of table entry #3
1
2 + 2z
Y z = X z H z = ---------------------------------------------------------------1
1 1 1 2
1 z 1 --- z --- z
6
6
1
2 + 2z
= -----------------------------------------------------------------------1 1
1
1 1
1 z 1 + --- z 1 --- z
2
3
We now use a partial fraction expansion over the three real
poles 1, -1/3, and 1/2
A2
A1
A3
Y z = ---------------- + -------------------- + -------------------1
1 1
1 1
1z
1 + --- z
1 --- z
3
2
Solving for the coefficients
ECE 2610 Signals and Systems
829
2 + 2z
A 1 = ------------------------------------------------- 1 + 1--- z 1 1 1--- z 1
2
3
+ 2- = 6
= 2----------4--- 1--
3 2
=1
2 + 2z
A 2 = ----------------------------------------------1
1 1
1 z 1 --- z
26
= ------------ = 2--5
5
4 --2
= 3
2 + 2z
A 3 = ----------------------------------------------1
1 1
1 z 1 + --- z
2 + 4 = 18
= -----------------5--5
1
3
=2
Finally,
18 5 6 - ------------------2 5 - ------------------Y z = --------------1
1 1
1 1
1z
1 --- z
1 + --- z
2
3
and using #6 to inverse transform term-by-term
n
2--- 1 n
18
1
830
p = 1.0000e+00
5.0000e-01
-3.3333e-01
K = []
0.4z
2 2.4z 0.4z
1
2
1 0.3z 0.4z
1 2.1z
1 2.1z
Y z = 1 + -------------------------------------------1
2
1 0.3z 0.4z
ECE 2610 Signals and Systems
831
1 2.1z
1 2.1z
- = ---------------------------------------------------------Y z = -------------------------------------------1
2
1
1
1 + 0.5z 1 0.8z
1 0.3z 0.4z
A2
A1
= ----------------------- + ----------------------1
1
1 + 0.5z
1 0.8z
The coefficients are
1
1 2.1z
A 1 = -----------------------1
1 0.8z
1 + 4.2
= ---------------- = 2
1 + 1.6
= 2
1 2.1z
A 2 = -----------------------1
1 + 0.5z
1 2.625
= ---------------------- = 1
1 + 0.625
= 1.25
Finally,
2 - ----------------------1 Y z = 1 + ----------------------1
1
1 + 0.5z
1 0.8z
and
n
y n = n + 2 0.5 u n 0.8 u n
We can again check this with residuez(); which will
automatically perform long division
>> [A,p,K] = residuez([2 -2.4 -0.4],[1 -0.3 -0.4])
A = -1
2
832
p = 8.0000e-01
-5.0000e-01
K = 1 <== Long division term
0n
j
un
(8.18)
Ak pk u n + H e
0
j
0n
j
un
(8.19)
k=1
833
n = -5:50;
x = cos(2*pi/20*n).*ustep(n,0);
y = filter(5,[1 -1.5 0.8],x);
subplot(211)
stem(n,x,'filled')
axis([-5 50 -1 1]); grid
ylabel('x[n]')
subplot(212)
stem(n,y,'filled')
axis([-5 50 -30 30]); grid
ylabel('y[n]')
xlabel('Time Index (n)')
834
x[n]
0.5
0
0.5
1
5
10
15
20
25
30
35
40
Transient Interval
45
50
X= 40
Y= 22.6556
y[n]
20
0
20
5
10
15
20
25
30
Time Index (n)
35
40
45
50
0?
What is the filter gain at
From the plot above we see that in steady-state output peak
amplitude over the input peak amplitude is about
0 22.66
------------- = 22.66
Gain at
1
We can check this by finding the filter frequency response
magnitude
>> w = [0 0.1*pi]; % input two frequency values
>> H_2pts = abs(freqz(5,[1 -1.5 0.8],w))
H_2pts =
1.6667e+01
The exact gain is 22.65, so the value from the plot is very
close
835
Second-Order Filters
Second-Order Filters
Second-order IIR filters allow for the possibility of complex
conjugate pole and zero pairs, yet still have real coefficients
The general second-order system function is
1
b0 + b1 z + b2 z
H z = -------------------------------------------1
2
1 a1 z a2 z
(8.20)
(8.21)
The coefficients are related to the roots (poles & zeros) via
b1 b0 = z1 + z2
a1 = p1 + p2
b2 b0 = z1 z2
a2 = p1 p2
(8.22)
836
Second-Order Filters
p 1 2
a 1 a 1 + 4a 2
= ---------------------------------2
2
where
r =
a2
1
a1
---------------
= cos
2 a 2
Zeros: Similar results hold for the zeros if we factor out b 0
and then replace a 1 with b 1 b 0 and replace a 2 with
b2 b0
837
Second-Order Filters
3
3
3
+
2z
+
2.5z
H z = --------------------------------------------- = --------------------------------------------------1
2
1
2
1 1.5z + 0.8z
1 1.5z + 0.8z
1
Apply the quadratic formula to the numerator and denominator to find the zeros and poles
2
z 1 2
2 2 4 3 2.5 = ---------------------------------------------------23
= 0.3333 j0.8498 = 0.9129e
j1.9446
p 1 2
j0.5762
838
Second-Order Filters
Impulse Response
Using a partial fraction expansion we can inverse transform
any rational H z back to the impulse response h n
Given
1
b0 + b1 z + b2 z
b0 + b1 z + b2 z
H z = --------------------------------------------- = ------------------------------------------------------ (8.23)
1
2
1
1
1 p1 z 1 p2 z
1 a1 z a2 z
we first perform long division to reduce the numerator order
by one
It can be shown that the partial fraction expansion will be of
the form
b2
A1
A2
H z = ----- + ---------------------- + ---------------------a 2 1 p z 1 1 p z 1
1
(8.24)
where
1
Ak = H z 1 pk z
z = pk
(8.25)
839
Second-Order Filters
For complex conjugates poles further simplification is possible because A 1 and A 2 will also be complex conjugates
Complex Conjugate Poles: To simplify (8.25) for this case
we first write A 1 and p 1 in polar form
A 1 = e
p 1 = re
(8.26)
n j n +
A 1 p 1 + A 2 p 2 = r e
n j n +
+ r e
(8.27)
= 2r cos n +
and (8.25) specializes to
b2
n
----- n + 2r cos n + u n
a2
(8.28)
We also see from this form that if we place the poles on the
unit circle, the impulse response will contain a pure sinun
n
soid, since r 1 = 1
Example: Conjugate Poles Inside the Unit Circle
Find the impulse response corresponding to
1
3+z
H z = -----------------------------------------------------------------------------j 4 1
3 j 4 1
1 3
--- e
z
1 --- e
z
4
4
The partial fraction expansion is of the form
ECE 2610 Signals and Systems
840
Second-Order Filters
A1
A2
H z = -------------------------------- + ----------------------------------3 j 4 1
3 j 4 1
1 --- e
z
1 --- e
z
4
4
We know that A 2 = A *1
4 j 3
3 + --- e
3
= --------------------------1+j
3+z
A 1 = ---------------------------------3 j 4 1
z
1 --- e
4
= 2.867e
4 j 4
= --- e
3
j1.020
841
Second-Order Filters
n = 0:20;
h_anal = 2*2.867*(3/4).^n.*cos(pi/4*n - 1.02);
subplot(211)
stem(n,h_anal,'filled')
grid
ylabel('h_{analysis}[n]')
subplot(212)
x = [1 zeros(1,20)];
h_sim = filter([3 1], conv([1 -3/4*exp(j*pi/4)],...
[1 -3/4*exp(-j*pi/4)]),x);
stem(n,h_sim,'filled')
grid
ylabel('h_{simulation}[n]')
xlabel('Time Index (n)')
>>
>>
>>
>>
analysis
[n]
4
2
0
2
10
12
14
16
18
20
16
18
20
They agree!
simulation
[n]
6
4
2
0
2
8
10
12
Time Index (n)
14
842
Second-Order Filters
Frequency Response
j2
b0 + b1 e + b2 e
H e = ---------------------------------------------------
j
j2
1 a1 e a2 e
(8.29)
Highpass
j
He
j
He
Bandpass
Bandstop (notch)
j
He
j
He
With just two poles and two zeros the filter action achievable
is limited
Lowpass/Highpass: Place zeros on the unit circle as a conjugate pair and poles inside the unit circle as a conjugate pair
1
1 z + z
1 2 cos
H z = ------------------------------------------------------------- 2 z 1 + r 2 z 2
1 2r cos
ECE 2610 Signals and Systems
(8.30)
843
Second-Order Filters
z-Plane
1z
H z = ------------------------------------------------------------- 0 z 1 + r 2 z 2
1 2r cos
(8.31)
z-Plane
0
r
844
Bandstop (notch):
1
0 z + z
1 2 cos
H z = ------------------------------------------------------------- 0 z 1 + r 2 z 2
1 2r cos
(8.32)
0
1
j
20log 10 H e (dB)
dB
Transition Band
Passband
Stopband
50
0
--3
--2
845
A variety of IIR filters can be designed to meet these requirements, one such filter type is an elliptic filter, which is available in the MATLAB signal processing toolbox
>> ellipord(2*(pi/3/(2*pi)),2*(pi/2/(2*pi)),1,50)
ans = 5 % The required filter order, N, to meet
% the design requirements.
>> [b,a] = ellip(5,1,50,2*(pi/3/(2*pi)));%design filter
>> b = 1.9431e-02 2.1113e-02 3.7708e-02 3.7708e-02
2.1113e-02
1.9431e-02 % M=5
>> a 1.0000e+00 -2.7580e+00 4.0110e+00 -3.3711e+00
1.6542e+00 -3.7959e-01 % N=5
>> zplane(b,a)
>> w = -pi:(pi/500):pi;
>> H = freqz(b,a,w);
>> subplot(211); plot(w,20*log10(abs(H)))
>> subplot(212); plot(w,angle(H))
1
0.8
0.6
Imaginary Part
0.4
0.2
0
0.2
0.4
0.6
0.8
1
1
0.5
0
Real Part
0.5
846
0
|H(ej)|
dB
1 dB
20
40
50
60
0
hat()
--2
H(e )
2
0
2
The fifth-order elliptic design has more than met the amplitude response requirements as it achieves the -50 dB gain
= 2
level before
The complete H z is
Hz =
1
0.01943
+ 0.02111z + 0.03771z + 0.03771z + 0.02111z + 0.01943z --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1
2
3
4
5
1 2.7580z + 4.0110z 3.3711z + 1.6542z 0.3796z
847
848