# Matlab differene equation question

• Apr 13th 2009, 07:13 PM
mrtwigx
Matlab differene equation question
I hav a question im not quiet sure how to do on matlab. Here it is:

Consider the following difference equation:
q(n) = 2*q(n-1) + q(n-2) - 2*q(n-3)

The analytical solution of the difference equation will be in the form
q(n) = a(1) + a(2)*(-1)^n + a(3)*2^n

Write down the system of linear equations in a(1), a(2), a(3) so that q(0) = 1
q(1) = 2, q(2) = 2.5. Use Matlab to find the values for a(1), a(2), a(3). Hand in your Matlab commands.

Usually I would do this by coming up with three simultaneous equations and solving them manually (or with a calculator) but this asks specifically for Matlab, and we havnt done simultanious equations, so i'm assuming theres another way, and if not mabe someone could run me through simultanious equations on Matlab.
Any help is greatly appreciated.
• Apr 13th 2009, 07:38 PM
CaptainBlack
Quote:

Originally Posted by mrtwigx
I hav a question im not quiet sure how to do on matlab. Here it is:

Consider the following difference equation:
q(n) = 2*q(n-1) + q(n-2) - 2*q(n-3)

The analytical solution of the difference equation will be in the form
q(n) = a(1) + a(2)*(-1)^n + a(3)*2^n

Write down the system of linear equations in a(1), a(2), a(3) so that q(0) = 1
q(1) = 2, q(2) = 2.5. Use Matlab to find the values for a(1), a(2), a(3). Hand in your Matlab commands.

Usually I would do this by coming up with three simultaneous equations and solving them manually (or with a calculator) but this asks specifically for Matlab, and we havnt done simultanious equations, so i'm assuming theres another way, and if not mabe someone could run me through simultanious equations on Matlab.
Any help is greatly appreciated.

What have you done in matlab?

CB
• Apr 13th 2009, 08:00 PM
mrtwigx
Quote:

Originally Posted by CaptainBlack
What have you done in matlab?

CB

Im only halfway through my first applied maths course (stage one) so probably not much. We'v done basic stuff like solving simple equations and drawing graphs. we'v done difference equations which involves analytical technique, for loops to do things like growh models and predator/prey models, and a few other things. Wev done Nonlinear equations which involves Newton-Raphson method, and have just started the bisection method, which involves using booleons. And I think thats about it.
• Apr 14th 2009, 11:29 PM
CaptainBlack
Quote:

Originally Posted by mrtwigx
Im only halfway through my first applied maths course (stage one) so probably not much. We'v done basic stuff like solving simple equations and drawing graphs. we'v done difference equations which involves analytical technique, for loops to do things like growh models and predator/prey models, and a few other things. Wev done Nonlinear equations which involves Newton-Raphson method, and have just started the bisection method, which involves using booleons. And I think thats about it.

Have you done any matrix calculations?

CB
• Apr 15th 2009, 12:41 AM
nzmathman
Quote:

Originally Posted by mrtwigx
Im only halfway through my first applied maths course (stage one) so probably not much. We'v done basic stuff like solving simple equations and drawing graphs. we'v done difference equations which involves analytical technique, for loops to do things like growh models and predator/prey models, and a few other things. Wev done Nonlinear equations which involves Newton-Raphson method, and have just started the bisection method, which involves using booleons. And I think thats about it.

Hi there - amazing coincidence but we must be doing the exact same paper, MATHS162 at Auckland Uni? This question is in assignment 2 - which is due on the 30th April (2nd week after the break). If you've looked at the course book the next topic we are starting is called "Systems of linear equations" so we will be taught how to do it shortly (Wink)
• Apr 15th 2009, 02:25 PM
mrtwigx
Quote:

Originally Posted by nzmathman
Hi there - amazing coincidence but we must be doing the exact same paper, MATHS162 at Auckland Uni? This question is in assignment 2 - which is due on the 30th April (2nd week after the break). If you've looked at the course book the next topic we are starting is called "Systems of linear equations" so we will be taught how to do it shortly (Wink)

Wow that is amazing - we are doing the same paper (Happy) anyway thanks for that I should probably looked in there before I posted, but I assumed it was something we had already done, and since I couldnt find out how to do it in the section we hav already done I resorted to asking one here.