+ All Categories
Home > Documents > Using Matlab 03

Using Matlab 03

Date post: 17-Oct-2015
Category:
Upload: farid-anuar
View: 49 times
Download: 3 times
Share this document with a friend
Description:
Digital Signal ProcessingMatlab
23
DIGITAL SIGNAL PROCESSING USING MATLAB® LECTURE 3: Z-TRANSFORM Pn. Aqilah Baseri Huddin Prof. Dr. Salina A. Samad
Transcript
  • 5/27/2018 Using Matlab 03

    1/23

    DIGITAL SIGNAL PROCESSING USING

    MATLAB

    LECTURE 3: Z-TRANSFORM

    Pn. Aqilah Baseri Huddin

    Prof. Dr. Salina A. Samad

  • 5/27/2018 Using Matlab 03

    2/23

    DEFINITION OF Z-TRANSFORM

    The z-transform of a discrete-time signal x[n] is defined as thepower series

    In MATLAB:

    >> help ztrans

    Example: Find z-transform of =

    >> syms n>> f = cos((pi*n)/2);

    >> ztrans(f)

    ans =

    z^2/(z^2 + 1)

    n

    znxnxZzX ][)}({)(

  • 5/27/2018 Using Matlab 03

    3/23

    PROPERTIES OF Z-TRANSFORM

    Property

    1 Linearity 2 Time-shifting ( ) ()3 Scaling

    () (

    )

    4 Time reversal () ()5 Differentiation () 6 Multiplication

    ()() 12 ()(

    )

    7 Convolution () ()()

  • 5/27/2018 Using Matlab 03

    4/23

    Example 1:

    Let = 2 3 4, = 3 4 5 6 Find = ()()

    From definition of the z-transforms,

    Hence

    }6,5,4,3{)(}4,3,2{)( 21 nxnx

    x1 = [2,3,4]; x2 = [3,4,5,6];

    x3 = conv(x1,x2)

    x3 =

    6 17 34 43 38 24

    543213

    24384334176

    zzzzz)z(X

    PROPERTIES OF Z-TRANSFORM

  • 5/27/2018 Using Matlab 03

    5/23

    PROPERTIES OF Z-TRANSFORMExample 2:

    We can use the conv_m function in to multiply two z-domainpolynomials corresponding to noncausal sequences:

    Let = 2 3, = 2 4 3 5 Find = ()()

    From definition of the z-transforms

    Therefore X3(z) = 2z3+ 8z2+ 17z + 23 + 19z-1+ 15z-2

    }5,3,4,2{)(}3,2,1{)( 21 nxnx

    x1 = [1,2,3]; n1 = [-1:1];

    x2 = [2,4,3,5]; n2 = [-2:1];

    [x3,n3] = conv_m(x1,n1,x2,n2)x3 =

    2 8 17 23 19 15

    n3 =

    -3 -2 -1 0 1 2

  • 5/27/2018 Using Matlab 03

    6/23

    PROPERTIES OF Z-TRANSFORMTo divide one polynomial by another, we need an inverse operation called

    deconvolution.In Matlab we use deconv, i.e. [p,r] = deconv(b,a) where we are dividingb by a in a polynomial part p and a remainder r.

    Example,

    We divide polynomial X3(z) in Example 1 by X1(z):

    x3 = [6,17,34,43,38,24]; x1 = [2,3,4];

    [x2, r] = deconv(x3,x1)

    x2 =

    3 4 5 6

    r =

    0 0 0 0 0 0

  • 5/27/2018 Using Matlab 03

    7/23

    Z-TRANSFORM PAIRS

  • 5/27/2018 Using Matlab 03

    8/23

    Z-TRANSFORM INVERSIONA Matlab function residuez is available to compute the residue

    part and the direct (or polynomial) terms of a rational function in z-1.Let

    Therefore we can find the Residues (R), Poles (p) and Direct terms

    (C) of X(z).

    NM

    k

    kk

    N

    k k

    k

    xxNN

    MM

    zCzp

    R

    RzR;za....za

    zb....zbb)z(X

    01

    1

    1

    1

    1

    10

    1

    1

    [R, p, C] = residuez(b,a)

  • 5/27/2018 Using Matlab 03

    9/23

    Z-TRANSFORM INVERSION

    Lets look at an example:

    Consider the rational function:

    First rearrange X(z) so that it is a fucntion in ascending powers of z-1:

    Use matlab:

    143)( 2

    zz

    z

    zX

    21

    1

    22

    2

    143)143()(

    zz

    z

    zzz

    zzzX

    b = [0,1]; a = [3,-4,1];

    [R,p,C] = residuez(b,a)

    R =

    0.5000

    -0.5000

    p =

    1.0000

    0.3333

    C =

    []

  • 5/27/2018 Using Matlab 03

    10/23

    Z-TRANSFORM INVERSIONWe obtain:

    To convert back to the rational function form:

    So that we get:

    11

    311

    21

    1

    21

    zz)z(X

    [b,a] = residuez(R,p,C)

    b =

    0.0000

    0.3333

    a =

    1.0000

    -1.3333

    0.3333

    21

    1

    31

    341

    31

    zz

    z)z(X

  • 5/27/2018 Using Matlab 03

    11/23

    Z-TRANSFORM INVERSION

    Another example, compute the inverse z-transform:90

    901901

    1

    121 .z,

    )z.()z.()z(X

    b = 1; a = poly([0.9,0.9,-0.9])

    a =

    1.0000 -0.9000 -0.8100 0.7290

    [R,p,c] = residuez(b,a)

    R =

    0.2500 + 0.0000i

    0.5000 - 0.0000i

    0.2500

    p =

    0.9000 + 0.0000i0.9000 - 0.0000i

    -0.9000

    c = []

  • 5/27/2018 Using Matlab 03

    12/23

    Z-TRANSFORM INVERSION

    Using table 4.1:

    )()9.0(25.0)1()9.0)(1(9.0

    5.0)()9.0(25.0)( 1 nununnunx nnn

  • 5/27/2018 Using Matlab 03

    13/23

    Matlab verification:

    [delta,n] = impseq(0,-1,7);

    x = filter(b,a,delta) % check sequence

    x =

    Columns 1 through 7

    0 1.0000 0.9000 1.6200 1.4580 1.9683 1.7715Columns 8 through 9

    2.1258 1.9132

    x = (0.25)*(0.9).^n + (0.5)*(n+1).*(0.9).^n + (0.25)*(-0.9).^n % answersequence

    x =Columns 1 through 7

    0 1.0000 0.9000 1.6200 1.4580 1.9683 1.7715

    Columns 8 through 9

    2.1258 1.9132

  • 5/27/2018 Using Matlab 03

    14/23

    Z-TRANSFORM INVERSION

    Another Example. Determine the inverse z-transform of

    so that the resulting sequence is causal and contains no complex

    numbers.

    We will have to find the poles of X(z) in the polar form to determine theROC of the causal sequence.

    21

    1

    6402801

    2401

    z.z.

    z.)z(X

    b = [1,0.4*sqrt(2)]; a=[1,-0.8*sqrt(2),0.64];

    [R,p,C] = residuez(b,a)

    R = 0.5000 - 1.0000i

    0.5000 + 1.0000i

    p = 0.5657 + 0.5657i0.5657 - 0.5657i

    C = []

    Mp=abs(p) % pole magnitudes

    Ap=angle(p)/pi % pole angles in pi units

    Mp = 0.8000 0.8000Ap = -0.2500 0.2500

  • 5/27/2018 Using Matlab 03

    15/23

    Z-TRANSFORM INVERSION

    From the Matlab calculation, we have:

    = .+|.|

    + .

    |.|

    And from table 4.1 we have:

    sequencesidedrighttoduez 8.0

    )n(u)]nsin()n[cos(.

    )n(u)]ee(j)ee(.[.

    )n(ue.)j.()n(ue.)j.()n(x

    n

    njnjnjnjn

    njnnjn

    42

    480

    5080

    80508050

    4444

    44

  • 5/27/2018 Using Matlab 03

    16/23

    Z-TRANSFORM INVERSION

    Matlab Verification:

    [delta,n] = impseq(0,0,6);

    x = filter(b,a,delta) % check sequence

    x =

    1.0000 1.6971 1.2800 0.3620 -0.4096 -0.6951 -0.5243

    x = ((0.8).^n).*(cos(pi*n/4)+2*sin(pi*n/4)) %answer sequence

    x =

    1.0000 1.6971 1.2800 0.3620 -0.4096 -0.6951 -0.5243

  • 5/27/2018 Using Matlab 03

    17/23

    SYSTEMS IN THE Z-DOMAINTo determine zeros and poles of a rational H(z), we can use

    roots for both the numerator and denominator. (poly is theinverse of root)

    We can plot these roots in a pole-zero plot using zplane(b,a).

    This will plot poles and zeros given the numerator row/columnvector b and the denominator row/column vector a.

    (H(z) = B(z)/A(z)) We can calculate the magnitude and the phase responses of

    our system using freqz:

  • 5/27/2018 Using Matlab 03

    18/23

    SYSTEMS IN THE Z-DOMAIN

    Example:

    Given a causal system

    y(n) = 0.9y(n-1) + x(n)

    a. Find H(z) and sketch its pole-zero plot

    b. Plot |H(ejw)| and

  • 5/27/2018 Using Matlab 03

    19/23

    SYSTEMS IN THE Z-DOMAIN

    Solution using Matlab:

    a. use zplane function - >> b = [1,0]; a = [1,-0.9];>> zplane(b,a);

    >> title(Pole-Zero Plot)

    -1 -0.5 0 0.5 1

    -1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Real Part

    ImaginaryPart

    Pole-Zero Plot

    0 0.9

  • 5/27/2018 Using Matlab 03

    20/23

    SYSTEMS IN THE Z-DOMAIN

    B. To plot the magnitude and phase response, we usefreqz function:

    >> [H,w] = freqz(b,a,100);

    >> magH = abs(H); phaH = angle(H);

    >>

    >> subplot(2,1,1); plot(w/pi,magH); grid>> xlabel('frequency in pi units'); ylabel('Magnitude');

    >> title('Magnitude Response')

    >> subplot(2,1,2); plot(w/pi,phaH/pi); grid

    >> xlabel('Frequency in pi units'); ylabel('Phase in pi

    units');

    >> title('Phase Response')

  • 5/27/2018 Using Matlab 03

    21/23

    SYSTEMS IN THE Z-DOMAIN

    B. The plots:

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

    2

    4

    6

    8

    10

    12

    frequency in pi units

    Magnitude

    Magnitude Response

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-0.4

    -0.3

    -0.2

    -0.1

    0

    Frequency in pi units

    Phaseinpiunits

    Phase Response

  • 5/27/2018 Using Matlab 03

    22/23

    SYSTEMS IN THE Z-DOMAIN

    B. Points to note:

    We see the plots, the points computed is between 0 < < 0.99 Missing point at = To overcome this, use the second form of freqz:

    >> [H,w] = freqz(b,a,200,whole);

    >> magH = abs(H(1:101)); phaH = angle(H(1:101));Now the 101stelement of the array H will correspond to =

    Similar result can be obtained using the third form:

    >> w = [0:1:100]*pi/100;

    >> H = freqz(b,a,w);

    >> magH = abs(H); phaH = angle(H);

    Try this

  • 5/27/2018 Using Matlab 03

    23/23

    SYSTEMS IN THE Z-DOMAIN

    B. Points to note:

    Also, note that in the plots we divided the w and phaH

    arrays by so that the plot axes are in the units of and easier toread

    This is always a recommended practice!


Recommended