solving odes and plotting

Ive been trying to solve these equations -
d2x dt2 = 2 dy dt + x− M(x + E) Re3 − E(x−M) Rm3
d2y dt2 = −2 dx dt + y− My Re3 − Ey Rm3
z1 = x, z2 = dx dt , z3 = y, and z4 = dy dt
and plot the solution to get a graph looking something like this:
though my plot keeps coming ether empty with the moon and earth or having three separate solution line
how can i get it to plot the potions x,y like in the above picture

 Respuesta aceptada

Steven Lord
Steven Lord el 29 de Nov. de 2017

0 votos

Use the OutputFcn and OutputSel options. If you look at the "Restricted Three Body Problem" example on this documentation page you'll see that the pictures it creates bear some similarity to the picture you showed. If you look at the code for that example by editing the orbitode function, you'll see it uses odephas2 as the OutputFcn. The way you've formulated your problem, with z1 = x and z3 = y, means that you'll need to use the OutputSel option to tell the ODE solver to pass components 1 and 3 of the solution into the OutputFcn.
Both these options are described on the documentation page for the odeset function.

Más respuestas (0)

Etiquetas

Preguntada:

del
el 29 de Nov. de 2017

Respondida:

el 29 de Nov. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by