Transfer function to a Difference equation

Discussion in 'Homework Help' started by naickej4, Jul 9, 2016.

  1. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Hi All,
    Please can someone assist me in the below question, I firstly don't require the answer but I need to understand the method of arriving to the correct answer and I will attempt further workings and will appreciate if you can correct me along the way.

    Question:
    upload_2016-7-9_14-59-52.png

    I have attempted 15% of the solution but I need to know the appropriate way forward. Is my transfer function correct? Do I have to use partial fractions to split the Transfer function into fractions and then apply the Inverse Z Transforms methods to find the difference equations?
    Or is there a easy way to do it?
    NB: (I started learning Z transforms this week)

    My Attempted Solution:

    upload_2016-7-9_15-12-56.png

    Thank You.
     
  2. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hi there,

    Since you didnt seem to know how to go about this i'll provide a procedure but you'll have to apply it to your present problem. See if you can find the answer, and i am sure you will be able to :)

    First expand the denominator so it does not contain any complex factors.
    We then have a numerator N and denominator D:
    H(z)=N(z)/D(z)
    or for short just:
    H(z)=N/D

    Then set:
    yn=xn*N/D

    Then multiply both sides by D:
    yn*D=xn*N

    Expand, then divide by highest power of z:
    yn*D/z^n=xn*N/z^n

    then expand so that you have all the z's and their powers in the denominators of each term.

    Now replace each 1/z^n with a pseudo factor "[k-n]".

    Then solve for yn. The expression will look something like this:
    yn[k]=xn[k]-xn[k-1]-xn[k-2]+yn[k-1]+yn[k-2]

    but that's a different example made up just to show the form.

    Note that xn by itself is interpreted as xn/z^0 so the pseudo factor is [k-0] which turns into xn[k] or just xn.
    I used xn and yn here but you can use just x and y if you like.
     
  3. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Hi Sir, thank you. let me try this and I will post my re-attempted answer.
    thanks.
     
  4. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Hi Sir,
    Please find my attached answer. Please let me know if this is correct.
    thank you I appreciate all your help and time taken to teach me this.

    thank you.

    upload_2016-7-9_21-17-23.png
     
  5. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hi,

    Yes, that looks very good :)
     
    naickej4 likes this.
  6. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hello again,

    I see you asked about a long division problem in another part of the forum. That's interesting because you can check your results for this problem using long division too.
    For this problem, once you get the difference equation you can calculate several values in the output sequence yn if you use an input xn sequence with only a single '1' in it and the rest zeros. Calculate several output values using the difference equation, then do the long division, then compare the coefficients to the values you got from the difference equation. They should be the same for any number of output values, but if you test up to maybe 10 values that is probably good enough when the highest value of 'n' is '3' (as in xn[k-3]).

    So if you get output values like (these are completely made up values):
    yn={0,0,0,1,-2,3,4,2,0.5,0.001}

    and you get coefficients from the long division like:
    1,-2,3,4,2,0.5,0.001

    then the results should be correct.

    I think you will start to see that a lot of this stuff is a lot simpler than it looks sometimes, and z^-1 just represents a delay of 1 sample period.
     
  7. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Hi Sir, thanks a million for your guidance. Wow this method is cool.
    So going to try this out for the other question that I posted.
    Thank you.
     
  8. josh007

    Member

    Sep 20, 2015
    40
    1
    Greetings Mr AI,
    Is that a subscript "n"?
    Does it have to be yn[k] or can you write it as y[k] ?
    how do you pass a sequence those the difference equation?
    thanks.
    regards
    Joshy
     
  9. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Hi Joshy007,

    I think if you read what Mr AI said, quoted: "I used xn and yn here but you can use just x and y if you like."
    what do u mean pass a sequence?

    thanks
     
  10. josh007

    Member

    Sep 20, 2015
    40
    1
    I meant how do you pass a Sequence through the difference equation that was created???

    regards
    Joshy
     
  11. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hello Josh,

    The sequence to be passed is the sequence 'x', and i'll just use x here instead of xn.
    So 'x' is the input sequence, and 'y' is the output sequence. We have two sequences, one is input and one is output.

    To start, we assign values to the two sequences. The sequence 'y' is zero to start because nothing has been calculated yet, so we create a sequence with say 10 zeros:
    y={0,0,0,0,0,0,0,0,0,0}

    We associate each of those zeros with a certain selector 'k' so if we had 'k' in each position that was selected by that 'k' we would have:
    g={1,2,3,4,5,6,7,8,9,10}

    so when k=3 for example, g[k]=3, and when k=7, g[k]=7.
    In the sequence for 'y' however, we have all zeros:
    y={0,0,0,0,0,0,0,0,0,0}

    so for any 'k' we have y[k]=0, but that will change as we do the calculations one by one.

    Now the input sequence we will make will have a single 1, at position k=3, so we have:
    x={0,0,1,0,0,0,0,0,0,0}

    and you'll note that x[k] is zero for all k except for k=3, so x[3]=1.

    To make this example simpler we will use the difference equation:
    y[k]=x[k]-0.5*y[k-1]-x[k-1]

    Ok, now that we have the two sequences and the difference equation, we can start doing the calculations.
    Now if we were to start with k=1 then when we get to the term with y[k-1] or x[k-1] we would end up trying to find the sequence element y[0] and x[0], which for this example dont exist. That's not that they can not exist however, but for this example we chose to use the enumeration:
    {1,2,3,4,5,6,7,8,9,10}

    so k=0 is not defined. In many problems k is defined when k=0, so we'd have to change that enumeration to:
    {0,1,2,3,4,5,6,7,8,9}

    for example, but for this example we start with k=1. It doesnt matter that much but k=0 doesnt work in some program languages.

    Ok, so we will start with k=2 (so that we dont get the condition k=0):
    When k=2, the difference equation looks like this:
    y[2]=x[2]-0.5*y[2-1]-x[2-1]

    which of course is the same as:
    y[2]=x[2]-0.5*y[1]-x[1]

    Now since x[2]=0 and x[1]=0 and y[1]=0 that means we have:
    y[2]=0-0.5*0-0=0

    So y[2] dosent change, it stays at zero. So the output sequence stays the same as it was:
    y={0,0,0,0,0,0,0,0,0,0}

    Now we increment k, k=k+1, and we get k=3 now. So the difference equation looks like this:
    y[3]=x[3]-0.5*y[3-1]-x[3-1]

    and again all we did was replace k with it's current value of 3. That now is the same as:
    y[3]=x[3]-0.5*y[2]-x[2]

    and since x[3]=1 and y[2] and x[2] are both zero, we have:
    y[3]=1-0.5*0-0=1

    So y[3] now equals 1, so we replace that with 1 in the output sequence which gives us:
    y={0,0,1,0,0,0,0,0,0,0}

    We now have two values calculated in the output sequence where the first was 0 and the second was 1.

    To continue, we increment k once more and get k=k+1=4. The difference equation is now:
    y[4]=x[4]-0.5*y[4-1]-x[4-1]

    which is the same as:
    y[4]=x[4]-0.5*y[3]-x[3]

    and since x[4]=0 and y[3]=1 and x[3]=1, we have:
    y[4]=0-0.5*1-1=0-0.5-1=-1.5

    and we again update the output sequence:
    y={0,0,1,-1.5,0,0,0,0,0,0}

    So you see we have three output values calculated now, two are non zero..
    If we continue in this manner up to k=10 and using floating point for the calculations we would end up with:
    y={0,0,1,-1.5,0.75,-0.375,0.1875,-0.09375,0.046875,-0.0234375}

    So the procedure is:
    1. Create an empty 'y' sequence with all zeros.
    2. Start with some significant k.
    3. Insert k into the difference equation.
    4. Simplify, grab the values for any y or x in the equation.
    5. Do the resulting calculation.
    6. Update the y sequence in the k position that you calculated for.
    7. Increment k, repeat steps 3 to 7 until you reach the last k needed.

    This is basically the same way you would do it in program code such as in a microcontroller or something like that. The difference equation may represent a filter of some kind. You would just use a loop like "for k=3 to 10 do" or similar.

    You'll probably see that this is a LOT easier to actually DO then to DESCRIBE how to do :)
     
    Last edited: Jul 12, 2016
  12. josh007

    Member

    Sep 20, 2015
    40
    1
    Hi Mr AI, I'm really impressed at this explanation sir. Are you some sort of lecturer or Professor?

    I'm not trying to flatter you, but this explained it better then my lecturer's notes. I am relieved to have asked this question.
    Do you know any other sources that can give me examples on this topic?

    I am not purchasing the prescribed text book (too expensive) hence I need other good reliable sources on this topic.

    Gracias

    Regards
    Joshy
     
  13. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Thanks Mr AI for the detail explanation.
    Yeh Mr AI and WBahn always helps people on these forums, I think they are Professors ( I might be wrong).
    They did help me with some Circuit Analysis stuff that contributed to me passing that module.

    What is the name of the text book that you require? why don't you try to find it in a second hand book shop, that is what I do.

    thanks.
     
  14. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hello there Josh,

    I am retired now, so i only help people on line with electronics and electrical and related.
    During and after i left college i purchased books, lots of books, maybe 200 or more, on various topics on circuit design and related. I studied each one i detail in order to get a better understanding of electronics and even the universe itself. I did not really intend to go that far, but i found that a lot of stuff in the electrical field led to ideas about what happens in the universe as a whole so i ended up learning some things about that too :)
    It's hard to remember all that stuff though, so helping other people with their problems helps me to refresh some of what i learned in the past. When i dont remember something i look it up in one of my references if i still have it, or else search around online. It's too bad that we forget some things when we learn new things. All i can say about that is keep GOOD notes so you can refer to them in your later years. If you use computer storage for that, backup three or more times onto separate media, like CD or DVD disks, which last the longest i think.

    As far as books go, i am not sure what you are looking to learn exactly. What we did here was just a simple difference equation with a sequence, and that comes in under the general topic of Digital Signal Processing (DSP). In fact, DSP is quite a varied topic where sequences are just one basic part. Most of DSP works on sequences because that's the input and output form in many cases.
    There is a lot of stuff online that i did not have that's why i had to buy books, but today you can find a lot of stuff online in various fields. If you cant find it online you might find a second hand book on say Amazon for example. There are a lot of other sites that sell second hand books too. But one example, a book that was mentioned by naickej4 was found online in pdf format. So check around and see what you can find first.
    Topics in DSP include digital filtering and real world effects due to limited hardware resources for example.

    We could probably do more examples too.
     
  15. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Wow Sir,
    You now inspire me to do well in my studies so I can help others.

    thanks sir for this motivation. Sometimes when we young we tend not to take advice from our elders, we have a "know it all" attitude, and this leads us to disaster, hence disaster recovery methods have to be followed in our lives :)

    I should be starting to study filters this weekend so I might post some confusing questions.
    thank you.
     
  16. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hi again,

    Well that's nice to hear :=)
    If you do well in your studies then you are likely to do well in your field when you start to work somewhere.

    Filters, sounds interesting. Do you mean continuous time or discrete? I guess we'll find out soon enough :)
     
  17. naickej4

    Thread Starter Member

    Jul 12, 2015
    182
    2
    Hi Sir, For now mostly descrete. But I have to know both for the exam. We have a practical exam and thats whats making me to stress since I have not been exposed to much of the software that we have to use, but the examiner provided us with past year papers so it can prepare us for the practical exam. Like I learnt the other day how to work out DFT stuff but in the practical exam we have to write a program to work it out.
    Thank you.
     
  18. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hi,

    So you will have to write your own DFT program algorithm?
    What language will you be using?
    You should learn some program language anyway, but if you have your choice that would be nicer.
     
  19. josh007

    Member

    Sep 20, 2015
    40
    1
    WOW Sir, that is truly amazing!!!. 200 books. I am sure you must have been a genius while at school and college and you also very polite.
    I want to be a part time mathematician, what can I do to do this?
    DO you think its worth the while?
    regards
    Joshy
     
  20. MrAl

    Well-Known Member

    Jun 17, 2014
    2,418
    488
    Hi again,

    Well gee thanks :)
    You should really talk to a guidance counselor at your chosen college to find out more about a career in mathematics. You got me curious now though. How much math have you had already, and i would think you like math a lot then ?
     
Loading...