# Thread: Matlab problem - solving a simple differential equation

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

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

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

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

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

Then:

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

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

CB

3. Thanks for the help! I forgot to reply...