Shop OBEX P1 Docs P2 Docs Learn Events
Difference equation — Parallax Forums

Difference equation

mona0783mona0783 Posts: 5
edited 2011-02-01 18:33 in BASIC Stamp
I was given a difference equation ( Y(n+2) + Y(n) = 0 ), and I am supposed to program it onto the Basic Stamp. I know I should know how to do this but I don't even know where to start. Can anyone help?
Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-01 16:49
    You're going to need more information than that. All that says is that the value of Y at time n+2 plus the value of Y at time n is zero. You can solve for Y(n+2) like you would for any other equation, but that doesn't tell you much. What else do you know about the system?
  • mona0783mona0783 Posts: 5
    edited 2011-02-01 16:57
    I thought so too. But he just said upload the equation onto the BS2 and plot the solution. He said it should look like a triangle wave. The solution to the difference equation is Y(n) = sin((pi/2)n).
  • mona0783mona0783 Posts: 5
    edited 2011-02-01 16:59
    Oh Im sorry the initial conditions are Y(0) = 1 and Y(1) = 1
  • mona0783mona0783 Posts: 5
    edited 2011-02-01 17:41
    Wrong again Y(0) = 0 and Y(1) = 1
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-01 18:27
    There's no built-in plotting capability in the Stamps and there's limited trig functionality (read the Stamp Manual section on SIN and COS for details). You might look at StampPlot Pro which is a PC program that is designed to work with a Stamp for plotting values. Use the Downloads button on Parallax's main webpage. I think it's under Stamp downloads.

    You might ask your instructor for more information.
  • mona0783mona0783 Posts: 5
    edited 2011-02-01 18:33
    Thank you :)
Sign In or Register to comment.