# Matlab problem - solving a simple differential equation

• Mar 4th 2010, 12:18 PM
Svenson
Matlab problem - solving a simple differential equation
Hi!

I have been stuck with Matlab all day trying to solve a differential equation. I have found several tutorials on this subject but still didn't manage to solve my equation.

Please have a look at the attached pictures. I wrote down the diff equation and also made a scan of a print from Matlab of what I have written. The text on either sides of the line are in separate files.

My problem: I want to get a solution for y but for some reason Matlab only gives the initial value of y (which is zero). It seems like it doesn't solve the equaiton.

I wonder what I could have done wrong? Especially the region I marked with red.

I would appreciate any feedback that could help me solve this, so I can go on with my work... :P

/Anders
• Mar 5th 2010, 04:41 AM
CaptainBlack
Quote:

Originally Posted by Svenson
Hi!

I have been stuck with Matlab all day trying to solve a differential equation. I have found several tutorials on this subject but still didn't manage to solve my equation.

Please have a look at the attached pictures. I wrote down the diff equation and also made a scan of a print from Matlab of what I have written. The text on either sides of the line are in separate files.

My problem: I want to get a solution for y but for some reason Matlab only gives the initial value of y (which is zero). It seems like it doesn't solve the equaiton.

I wonder what I could have done wrong? Especially the region I marked with red.

I would appreciate any feedback that could help me solve this, so I can go on with my work... :P

/Anders

You derivative function does not return the derivative vector.

You have a differential equation of the form:

$\ddot{y}=f(t, \dot{y},y)$

You turn this into a first order system by introducing the state vector:

$
\bold{y}=\left[ \begin{array}{c} y \\ \dot{y} \end{array}\right]
$

Then:

$
\dot{\bold{y}}=\left[ \begin{array}{c} \dot{y} \\ f(t, \dot{y},y) \end{array}\right]
$
$
\left[ \begin{array}{c} \bold{y}_2 \\ f(t, \bold{y}_2,\bold{y}_1) \end{array}\right]
$

It is ths $\dot{\bold{y}}$ that your derivative function should be returning.

CB
• Mar 15th 2010, 04:33 AM
Svenson
Thanks for the help! I forgot to reply...