Coupled Differential equation of second order in matlab

2.3k Views Asked by At

I have a problem solving a system of differential equations of second order in matlab: $$ \left\{ \begin{array}{l l}\frac{d^2y}{dt^2}= \frac{-y}{(x^2+y^2)^{3/2}}\\ \frac{d^2x}{dt^2}= \frac{-x}{(x^2+y^2)^{3/2}} \end{array} \right. $$ I know, that i need to rewrite $x=u_1$ and$\frac{dx}{dt}=u_2 $ (same with $y=s_1$ and $\frac{dy}{dt}=s_2$ ) and make it to a system of 4 differential equations of the second order. $$\left\{ \begin{array}{l l}u'_1=u_2\\ u'_2= \frac{-u_1}{(s_1^2+u_1^2)^{3/2}}\\s'_1=s_2\\ s'_2= \frac{-s_1}{(s_1^2+u_1^2)^{3/2}} \end{array} \right. $$I know that i need to use runge-kutta and ode45 in matlab, but i don't know how to make everything work. How do I set up a system of 4 differential equations and make it work with matlab?