EE-323 DIIGITAL SIGNAL PROCESSING
LAB REPORT 02
                 6TH SEMESTER (SPRING 2018)
Submitted to: Engr. Komal Munir
Submitted by: Syeda Ume Rubab
              16-EE-03
      Data presentation (0-5)       Data Analysis and interpretation (0-5)
        DEPARTMENT OF ELECTRICAL ENGINEERING
      UNIVERSITY OF ENGINEERING AND TECHNOLOGY
                                TAXILA
                                   LAB No. 02
             Evaluation of Z-transform and Pole/Zero Plots
Objective:
      To understand how to perform Z-Transform in MATLAB. To understand different
       MATLAB command related to the evaluation of transfer functions, poles, zeros and
       their plots.
Introduction:
Theory:
NAME: SYEDA UME RUBAB                                                     Reg #:16-EE-03
NAME: SYEDA UME RUBAB   Reg #:16-EE-03
Lab Tasks:
   1. Write a user-defined MATLAB function to compute Z-transform through following
        relation:
                                                ∞
                                       𝑋(𝑧) = ∑ 𝑥(𝑛)𝑧 −𝑛
                                              𝑛=−∞
                    ℎ𝑒𝑟𝑒 𝑥(𝑛)𝑖𝑠 𝑑𝑖𝑠𝑐𝑟𝑒𝑡𝑒 − 𝑡𝑖𝑚𝑒 𝑖𝑛𝑝𝑢𝑡 𝑎𝑛𝑑 𝑧 𝑖𝑠 𝑠𝑦𝑚𝑏𝑜𝑙𝑖𝑐 𝑣𝑎𝑟𝑖𝑏𝑙𝑒
   Code:
function X=z_transform(x)
syms z;
sum=0;
n=length(x)-1;
for i=0:1:n;
    X=x(i+1)*z^(-1*i);
    sum=sum+X;
end
X=sum
end
   2. Use the function defined in Task 1 to compute Z-transform of the following signals
          i.    x(n) = cos(2πFn)       here F = 10Hz
Code:
F=10;
x=cos(2*pi*F*n);
z_transform(x)
Output:
   X =1/z + 1/z^2 + 1/z^3 + 1/z^4 + 1
         ii.    x(n) = [2,4,5,7,1]
Code:
x=[2 4 5 7 1];
z_transform(x)
Output:
X = 4/z + 5/z^2 + 7/z^3 + 1/z^4 + 2
NAME: SYEDA UME RUBAB                                                        Reg #:16-EE-03
         iii.    x(n) = [0,0,1,2,5,7,0,1]
Code:
 x=[0 0 1 2 5 7 0 1];
z_transform(x)
Output:
X = 1/z^2 + 2/z^3 + 5/z^4 + 7/z^5 + 1/z^7
   3. Use MATLAB command ‘ztrans’ to compute Z-transform of following (use ‘syms’
        command to define inputs).
                       𝒌𝑻              𝒇𝒐𝒓 𝒌 ≥ 𝟎
           i.    𝒂𝒌 = { 𝒔
                       𝟎              𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
Code:
syms a k T;
a=k*T;
X=ztrans(a)
Output:
X= (T*z)/(z - 1)^2
          ii.    x[n]= an
Code:
syms a n;
x=a^n;
X=ztrans(x)
Output:
X = -z/(a - z)
   4. We know that a transfer function is a ratio of polynomials with ascending power of 𝑧-1.
        Transfer functions are specified by their numerator and denominator polynomials. In
        MATLAB, NUM and DEN are row vectors listing the numerator and denominator
        coefficients in descending order of z by default. For example, the polynomial 𝑧2 + 2𝑧 +
        10 is specified as [1 2 10]. For discrete-time transfer functions, it is highly
        recommended to make the length of the numerator and denominator equal to ensure
        correct results. Define vectors in MATLAB to express following transfer function with
        numerator and denominator polynomials.
                                                        4 − 5𝑧 −1
                                            𝐻(𝑧) =
                                                     8 + 3𝑧 −1 + 𝑧 −2
NAME: SYEDA UME RUBAB                                                           Reg #:16-EE-03
         Use ‘tf” command to generate transfer function from NUM and DEN vectors like
         tf(NUM,DEN,1). Use ‘roots’ command to compute roots of NUM and DEN
         polynomials. Show the pole/zero plot of H(z) using ‘zplane’ command.
Code:
num=[4 -5 0]
den=[8 3 1]
z=tf(num,den,1)
x=roots(num)
y=roots(den)
zplane(x,y)
Output:
z=
 4 z^2 - 5 z
 ---------------
 8 z^2 + 3 z + 1
Sample time: 1 seconds
Discrete-time transfer function.
x=
     0
  1.2500
y=
 -0.1875 + 0.2997i
 -0.1875 - 0.2997i
NAME: SYEDA UME RUBAB                                                           Reg #:16-EE-03
    5. Consider the following transfer function:
                                             4𝑧 −1 (1 − 0.5𝑧 −1 )(1 − 2𝑧 −1 )
                                  𝐻(𝑧) =
                                         (1 + 0.3𝑧 −1 )(1 − 0.4𝑧 −1 )(1 + 0.6𝑧 −1 )
        Represent this transfer function in vector and object form and then computer zeros,
        poles and gain using ‘tf2zp’ command and plot them using ‘pzmap’ command.
Code:
a=conv([0 4],[1 -0.5]);
num=conv([a],[1 -2])
b=conv([1 0.3],[1 -0.4]);
den=conv([b],[1 0.6])
H=tf(num,den,1)
[z,p,k]=tf2zp(num,den)
pzmap(H)
Output:
num = 0       4 -10      4
den = 1.0000      0.5000 -0.1800 -0.0720
H = 4 z^2 - 10 z + 4
 ------------------------------
 z^3 + 0.5 z^2 - 0.18 z - 0.072
z = 2.0000
    0.5000
p = 0.4000
   -0.6000
   -0.3000
k=4
NAME: SYEDA UME RUBAB                                                                 Reg #:16-EE-03
After Lab Questions:
   1. What are the differences between MATLAB commands ‘zplane’ and pzmap?
   2. How complex variable ‘z’ is related to complex variable ‘s’? Give expression.
   3. Give two practical applications of Z-Transform.
   4. How the values of real part (σ) of ‘s’ be translated into stability conditions in z-domain?
Discussion/ Conclusion:
NAME: SYEDA UME RUBAB                                                             Reg #:16-EE-03