Thread: ode45 Matlab
View Single Post
  #4  
Old November 27th, 2008, 10:58 PM
CaptainBlack's Avatar
CaptainBlack CaptainBlack is offline
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,375
Country:
Thanks: 667
Thanked 3,618 Times in 2,915 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

Quote:
Originally Posted by Rapha View Post
Hello.

that was very helpful, thank you very much (and yes, i could get ode45 to work).

But actually i kinda screwed it(sorry, i did not exactly realize what my problem was and asked for something different), because my problem is :

\ddot{x} = x + 2 \dot{y} - 0.9 \frac{x+0.1}{D_1} - 0.1 \frac{x-0.9}{D_2}

\ddot{y} = y - 2 \dot{x} - 0.9 \frac{y}{D_1} - 0.1 \frac{y}{D_2}

with D_1 = \sqrt{(((x+0.1)^2+y^2)^3)}

D_2 = \sqrt{(((x-0.9)^2+y^2)^3)}

i tried to find the IVP 1. order:

x_1 = x

\dot{x_1} = \dot{x} = x_2

y_1 = y

y_2 = \dot{y_1} = \dot{y}


=>
\dot{x_2} = x_1 + 2 y_2 - 0.9 \frac{x+0.1}{D_1} - 0.1 \frac{x-0.9}{D_2}

\dot{y_2} = y_1 - 2 x_2 - 0.9 \frac{y_1}{D_1} - 0.1 \frac{y_1}{D_2}

I did not realize that there are 4 functions: y_2(t), y_1(t), x_1(t), x_2(t)

I still want to solve this by using ode45.


Regards
Rapha
Now we have as state vector:

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

and derivative:

\dot{\bold{x}}=\left[ \begin{array}{c}
\bold{x}_3\\
\bold{x}_4\\ 
\bold{x}_1-2\bold{x}_4-0.9(\bold{x}_1+0.1)/D_1-0.1(\bold{x}_1-0.9)/D_2 \\ 
\bold{x}_2-2\bold{x}_3-0.9\bold{x}_2/D_1-0.1\bold{x}_2/D_2 
\end{array} \right]

where:

D_1 = \sqrt{(((\bold{x}_1+0.1)^2+\bold{x}_2^2)^3)}

D_2 = \sqrt{(((\bold{x}_1-0.9)^2+\bold{x}_2^2)^3)}

You will need to write a Matlab function to evaluate the derivative and pass that to ode45 (the derivative is now too complicated to be easily passed as an anonymous function).

(You cound simplify the derivative by collecting terms)

CB
__________________
Truth does not change because it is, or is not, believed by a majority of the people.

Giordano Bruno
Reply With Quote
The following users thank CaptainBlack for this useful post:
Donate to MHF