American International University-Bangladesh
Department of Electrical and Electronic Engineering
Digital Signal Processing Lab
Experiment #5
Objective: Introduction to Z-transform
Introduction: The z-transform of a sequence x(n) is given by
∞
x ( z ) = Z [ x ( n )] = ∑ x(n) z
n=∞
−n
where z is a complex variable. The set of z values for which X(z) exists is called the region of
convergence (ROC).
The inverse z-transform of a complex function X(z) is given by
1
x ( n ) = Z −1 [ X ( z )] =
2π j ∫ C
X ( z ) z n −1 dz
Where C is a counter clockwise contour encircling the origin and lying in the ROC.
Example 1: Assume we have a transfer function in the z-domain given by
z −1
X (z ) =
z
−1 −2
= 2 .
1 − 0.25 z − 0.375 z z − 0.25 z − 0.375
In the partial fraction form X(z) can be written as
c1 z c2 z − 0.8 z
X (z ) =
z 0.8 z
= + = + .
(z − 0.75)(z + 0.5) (z − 0.75) (z + 0.5) (z − 0.75) (z + 0.5)
The inverse z-transform of this is thus
[
x(n ) = (0.8)(0.75) + (− 0.8)(− 0.5) u (n )
n n
]
There are several MATLAB functions that could assist with calculating and analyzing these
results. We can find the roots of the denominator polynomial using
>> den = [1 -0.25 -0.375];
>> roots(den)
ans =
0.7500
-0.5000
We can then plot the zeros and poles either with
(1) zeros and poles in column vectors
>> z = [0]
z=
0
>> p = [0.75; -0.5]
p=
0.7500
-0.5000
>> zplane(z,p)
(2) numerator and denominator coefficients in row vectors
>> num = [0 1 0]
num =
0 1 0
>> den = [1 -0.25 -0.375]
den =
1.0000 -0.2500 -0.3750
>> zplane(num,den)
1
0.8
0.6
0.4
Imaginary Part
0.2
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
Real Part
Example 2:
We can find the impulse response (or inverse z-transform) of the polynomial based on the power
series expansion method using the “impz” function
h = impz(num,den,N) where N is the number of terms or coefficients to compute
>> h = impz(num,den,10)
h=
0
1.0000
0.2500
0.4375
0.2031
0.2148
0.1299
0.1130
0.0770
0.0616
MATLAB can also be used to help fund the partial fraction expansion
Assume you have a polynomial of the form
B( z ) b0 + b1 z −1 + b2 z −2 + L + bM z − M
H (z ) = =
A( z ) a 0 + a1 z −1 + a 2 z − 2 + L + a N z − N
This can be turned into a partial fraction expansion of the form
B(z ) R1 R2 R3 Rn
= + + + L + +K
A( z ) 1 − p1 z −1 1 − p 2 z −1 1 − p3 z −1 1 − p n z −1
B(z ) Rz R z Rz R z
= 1 + 2 + 3 +L+ n + K
A( z ) z − p1 z − p 2 z − p3 z − pn
where we can get the residues (coefficients), poles, and direct terms.
Thus for our example we have
z −1
X (z ) = 2
z
=
z − 0.25 z − 0.375 1 − 0.25 z −1 − 0.375 z − 2
so in MATLAB we would enter
>> num = [0 1];
>> den = [1 -0.25 -0.375];
>> [R,P,K]=residuez(num,den)
R=
0.8000
-0.8000
P=
0.7500
-0.5000
K=
[]
which corresponds to a partial fraction expansion of
− 0.8 z
X (z ) =
0.8 z
+ +0
z − 0.75 z + 0.5
[ ]
x(n ) = (0.8)(0.75) + (− 0.8)(− 0.5) u (n )
n n
Example 3:
The same residue function can used to convert back a partial fraction form into a rational form
also. Let us consider the partial function form expansion of the X(z) defined as
− 0 .8 z
X (z ) =
0 .8 z
+ +0
z − 0.75 z + 0.5
If we use MatLab to find the corresponding rational function we should use
>> R=[0.800 -0.800]
R=
0.8000 -0.8000
>> P=[0.7500 -0.5000]
P=
0.7500 -0.5000
>> K=0
K=
>> [b,a]=residuez(R,P,K)
b=
0 1 0
a=
1.0000 -0.2500 -0.3750
so that we have
z −1
X (z ) =
z
−1 −2
= 2
1 − 0.25 z − 0.375 z z − 0.25 z − 0.375
Example 4:
We can also plot the frequency response of a particular polynomial with freqz
For X (z ) =
z
we would enter
z − 0.25 z − 0.375
2
>> num = [0 1 0];
>> den = [1 -0.25 -0.375];
>> freqz(num, den, 512)
10
Magnitude (dB) 5
-5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (×π rad/sample)
0
Phase (degrees)
-50
-100
-150
-200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (×π rad/sample)
Here we have used the form
freqz(num,den,N)
where ‘num’ are the numerator coefficients, ‘den’ are the denominator coefficients, and ‘N’ is
the number of points to use in the plot which goes from 0 to π. An alternative form is to use
[H,f] = freqz(num,den,N,Fs)
plot(f, abs(H))
‘num’ and ‘den’ are the same. ‘Fs’ is the sampling frequency. ‘N’ values between 0 and Fs are
calculated. The response data versus frequency are stored in H.
>> num = [0 1 0];
>> den = [1 -0.25 -0.375];
>> [H,f] = freqz(num,den,512,8000);
>> plot(f,abs(H))
3
2.5
1.5
0.5
0 500 1000 1500 2000 2500 3000 3500 4000
Assignment:
1. Find the partial inverse z-transform of the H(z) through partial fraction expansion by Matlab.
4 − (7 / 4) z −1 + (1 / 4) z −2
X (z ) =
1 − (3 / 4) z −1 + (1 / 8) z − 2
ROC: |z|> ½
2. Draw the pole-zero plot of X(z)
3. Draw the magnitude and phase plot of X(ejw)