You are on page 1of 3

Example: Lets consider a difference equation

1
6 y(n ) 5 y ( n 1) + y ( n 2) = n , n 0
4
and
y (n 1) = 1, y (n 2) = 0

Z-Transform in Matlab
Z-transform is defined as

X ( z ) = x( n) z n

Taking z-transform
6Y ( z ) 5 {z 1Y ( z ) + y ( 1)} + { z 2Y ( z ) + z 1 y ( 1) + y ( 2)} =

n=0

or

X ( z ) = Z [ x(n )]
The inverse z-transform is denoted by
x(n ) = Z 1 [ X ( z )]
MatLab Symbolic Toolbox gives the z-transform of a function

+ z 2 ) Y ( z ) =

Y ( z) =
1
2
6 5z + z

4z
z 1 + 5 z 1
4z 1
4 z
1
1
4 z 1 z + 5 z

>> syms z n
>> iztrans((4*z/(4*z-1)-z^-1+5)/(6-5*z^-1+z^-2))

Example:
1
u (n )
4n
>> syms z n
>> ztrans(1/4^n)

2z
2z 1
>> syms z n
>> iztrans(2*z/(2*z-1))

ans =

ans =

4*z/(4*z-1)

(1/2)^n

x( n ) =

( 6 5z

4z
4 z 1

X ( z) =

ece308-19- 1

ans =
1/2*(1/4)^n+5/2*(1/2)^n-2*(1/3)^n
Therefore
n
n
n
11 51
1
y(n ) = + 2
2 4 22
3

ece308-19- 2

In Matlab deconv command is used to compute the inverse


z transform. ( Determine the values of x(n) for few samples)
deconv
Deconvolution and polynomial division

Therefore

x(0) = 1, x(1) = 4, x(2) = 5, x(3) = 6, x(4) = 32

Syntax
[q,r] = deconv(x,h)
Description
[q,r] = deconv(x,h) deconvolves vector x out of vector h, using long division. The
quotient is returned in vector q and the remainder in vector r such that v =
conv(u,q)+r.
If x and h are vectors of polynomial coefficients, convolving them is equivalent to
multiplying the two polynomials, and deconvolution is polynomial division. The result of
dividing h by x is quotient q and remainder r.
Examples
If
x = [1 2 3 4]
h = [10 20 30]
the convolution is
c = conv(x,h)
c=
10 40 100 160 170
Use deconvolution to recover h:

Partial fraction expansion with MatLab


The MatLab function residuez may be used to perform
partial fraction expansion of a z-transform.
N ( z ) b0 + b1 z 1 + ... + bM z M
X ( z) =
=
D ( z ) a 0 + a1 z 1 + ... + aN z N
The partial fraction expansion has the form
N (z )
r1
rN
=
+ ... +
+ k + k z 1 + ... + k M N 1 z ( M N )
1
D( z ) 1 p1 z
1 pN z1 1 2

120

Example: Find the partial fraction expansion of the following


z-transform
1 + 2 z 1 + z 2
X ( z) =
1 2 z1 + 4 z2

[q,r] = deconv(c,x)
q=
10 20 30
r=
0
0
0
0
0
0
This gives a quotient equal to v and a zero remainder.

Example:
Find the first five term of the inverse z-transform of
1 + 2z 1 + z 2
X (z) =
1 2 z 1 + 4 z 2

>> [r,p,k]=residuez([1,2,1],[1,-2,4])

>> b=[1 2 1];


>> a=[1 -2 4];
>> n=5;
>> b=[b zeros(1,n-1)];
>> [x,r]=deconv(b,a);
>> disp(x)
1 4 5 -6 -32

p=
1.0000 + 1.7321i
1.0000 - 1.7321i

r=
0.3750 - 0.9382i
0.3750 + 0.9382i

k =
0.2500

ece308-19- 3

ece308-19- 4

Pole-zero Diagram
The MatLab function zplane can display the pole-zero
diagram
Example:
1
z 1 + z 2
2
H ( z) =
3 1 2 2
1+ z + z
5
25
>> b=[0 1 1/2];
>> a=[1 3/5 2/25];
>> zplane(b,a)

Reference: Numerical Methods using MatLab, George


Lindfield, John Penny. Prentice Hall, 2000
Digital Signal processing A Practice Approach, E. C.
Ifeachor, B.W. Jervis, Prentice Hall,2002

ece308-19- 5

You might also like