z transform of difference equations

Discussion in 'Homework Help' started by count_volta, Sep 18, 2010.

  1. count_volta

    Thread Starter Active Member

    Feb 4, 2009
    Hi, I am pretty new to Z transforms, I need some help.

    I have the following difference equation:
    y(n) +0.25y(n-1) - .125y(n-2) = x(n-1)-0.5x(n-2)

    y(0) = 0

    All I need to do is get the transfer function H(z) and find the poles and zeros.

    Here is my attempt:

    Taking Z transform of the difference equation:

    y(z) + 0.25*z^-1*Y(z) - .125*z^-2*Y(z) = z^-1*X(z) - 0.5*z^-2*X(z)

    Then the transfer function is:
    H(z) = (Z^-1 - 0.5Z^-2) / (0.25z^-1 - .125Z^-2)

    Then I have poles at Z = 0 and Z=-0.5

    Now to check myself I used matlab. The matlab answer is very different from mine. This is what bothers me. Here is the matlab code.

    numz = [1 -0.5];
    denz = [1 (1/4) (-1/8)];
    DiscreteSystem = tf(numz,denz,-1);


    Transfer function:
    z - 0.5
    z^2 + 0.25 z - 0.125


    ans =


    So did I do something wrong, if so where? Thank you.
  2. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    You wrote

    You missed a part ... the term with just Y(z)


    or H(z)=(z-0.5)/(z^2+0.25*z-0.125)
  3. count_volta

    Thread Starter Active Member

    Feb 4, 2009
    LOL thanks, need to be more careful. I just needed confirmation that I'm doing it right. Especially whether or not I was taking Z transforms of the difference equation correctly. Glad all I did wrong was miss a term.

    Its also confusing how matlab expresses z transforms in terms of positive powers of Z. Have to go back and forth between the two versions to check my work. Lots of room for silly mistakes.
    Last edited: Sep 18, 2010
  4. count_volta

    Thread Starter Active Member

    Feb 4, 2009
    Now I need help taking the inverse Z transform. So I have the transfer function:

    H(z) = (z-0.5) / (z-0.25) (z+0.5)

    I need to find H(n). I did partial fractions on it and got:

    H(z) = ((-1/3) / (z-0.25)) + ((4/3) / (z+0.5))

    Then I look at a table of Z transforms and can't seem to find anything that matches. Here is a table of z transforms.


    If only this was Laplace transform I could easily do it. I guess I need help with the math itself. Can anyone help me out please?
  5. Georacer


    Nov 25, 2009