# Thread: Matlab differene equation question

1. ## 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.

2. 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

3. 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.

4. 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?