Lab. NO.
:14
                        Z-Transform and Inverse Z-Transform in Matlab
Lab. Objective: To Use Z-Transform and Inverse Z-Transform in Matlab.
Tools: Matlab, PC.
Thoery:
Z-Transform: Z-Transform is used to transform a discrete time sequence to frequency domain.
Inverse Z-Transform: Inverse Z-Transform is use to transform a frequency domain signal to discrete
time signal.
Converting discrete time signal to frequency domain via Z-Transform
Matlab Code:
%%transforming discrete time sequence to frequency domain%%
syms n z%Matlab built-inn function to define n and z
h=1/n-2;%defining time domain sequence
H=ztrans(h)%Matlab built inn command to transform t-domain sequence to f-domain
H1=simplify(H)%Matlab built-inn command to simplify the function
Output:
H=
ztrans(1/n,n,z)-2*z/(z-1)
H1 =
(ztrans(1/n,n,z)*z-ztrans(1/n,n,z)-2*z)/(z-1)
Converting transfer function from frequency domain to discrete time via Inverse Z-Transform:
%%transforming transfer function from frequency domain to discrete time domain%%
syms n z%Matlab built-inn function to define n and z
H=z-3/(3*z^-3+2);%defining transfer function in ferquency domain
h=iztrans(H)%Matlab built inn command to transform foe inverse z-transform
h1=simplify(h)%Matlab built-inn command to simplify the function
Output:
h=
iztrans(z,z,n)-1/2*sum((1/_alpha)^n,_alpha = RootOf(3*_Z^3+2))
h1 =
iztrans(z,z,n)-1/2*sum((1/_alpha)^n,_alpha = RootOf(3*_Z^3+2))
Finding the location of poles and zeros in Transfer function:
Matlab Code:
%%finding location of poles and zeros%%
syms z%Matlab built-inn function to define z-transform variable z
H=3*z^2-z-5/(3*z^-3+2*z^2-4*z-1);%defining transfer function in ferquency domain
num=[3 -1 -5];%defining numerator of the transfer function
den=[3 -3 2 -4 -1];%defining numerator of the transfer function
z=roots(num)%Matlab built-inn command for finding location of zeros
z=roots(den)%Matlab built-inn command for finding location of poles
Output:
z=
  1.4684
 -1.1350
z=
 1.3616
 -0.0723 + 1.0595i
 -0.0723 - 1.0595i
 -0.2171
Plotting of poles and zeros of Transfer function:
Matlab Code:
%%plotting of poles and zeros%%
syms z%Matlab built-inn function to define z-transform variable z
H=5*z^-3-6*z^2-5*z^-1+3/(3*z^-3+2*z^2-4*z-1);%defining transfer function in ferquency domain
num=[5 6 -5 1 3];%defining numerator of the transfer function
den=[3 -3 2 -4 -1];%defining numerator of the transfer function
z=roots(num)%Matlab built-inn command for finding location of zeros
p=roots(den)%Matlab built-inn command for finding location of poles
zplane(num,den)
legend('poles-zeros map')
grid on
Output:
Location of poles and zeros
z=
 -1.7292
 0.5620 + 0.5173i
 0.5620 - 0.5173i
 -0.5947
p=
 1.3616
 -0.0723 + 1.0595i
 -0.0723 - 1.0595i
 -0.2171
                                                                   poles-zeros map
                        1
                      0.5
     Imaginary Part
                      -0.5
                       -1
                             -1.5   -1   -0.5           0    0.5         1           1.5
                                                Real Part
Lab. Assignment:
Transfrom the given Transfer function from rational form to factored form in Matlab.
2z-4+5z3+5z2+7z-11/5z-3-5z+2
Solution:
Matlab Code:
%%expension of transfer function from rational form partial fraction form%%
syms z % defining the z-transform variable z
H=2*z^-4+5*z^3+5*z^2+7*z-11/5*z^-3-5*z+2;%defining the transfer function
num=[2 5 5 7 -11];%defining numerator of the transfer function
den=[5 -5 3];%defining numerator of the transfer function
[r p k]=residuez(num,den)%Matlab built-inn command for partial fraction expension
Output:
r=
 -0.5407 - 4.8330i
-0.5407 + 4.8330i
p=
 0.5000 + 0.5916i
 0.5000 - 0.5916i
k=
 1.4815 -3.7778 -3.6667