Simple Orbit problem Sun and Jupiter
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm trying to plot an orbit with the Sun and Jupiter only. I assumed circular orbit and all the simplicity posible still, my ode45 part does not work. Could you guys help me with this.
I put the code below. Why ode45 does not work.
The equation is a 2nd order diferential equation.
a''=-a - const* . I want to solve for a but ode45 does not even go inside the orbit function.
function SunsOrbit
% Simple 2 body problem with Jupiter and the Sun
%
%
%Setting up Constants
K.d=7.785e8 ; %km distance Jupiter-Sun
K.Mj=1.898e27; %kg
K.Msun= 1.989e30; %kg
K.mi=K.Mj*K.Msun/(K.Mj+K.Msun);
K.Vj=724.7800; %km/h Jupiter's velocity
K.Pj=K.Mj*K.Vj; % Jupiter's linear momentum
K.l=K.d*K.Pj; % Angular Momentum Modulus
K.G=6.67384e-11; % m3 kg-1 s-2
K.gamma = -K.G*K.Mj*K.Msun;
%
Inits=[-1/K.d^2*K.Vj,1/K.d^2*K.Vj];
ThetaRange=[0,2*pi];
[Theta,da]=ode45(@orbit,ThetaRange,Inits,[],K);
% Orbit's equation
function da=orbit(K)
da=zeros(1,2);
da(1)=(-1/r.^2).*K.Vj;
da(2)=((-1./r)+(-K.mi)./(K.l))*K.gamma;
2 个评论
Geoff Hayes
2014-10-9
Douglas - when you say that your ode45 part does not work, what exactly do you mean? Are you observing an error of some kind, and if so, what is it?
Running your code as is does produce the Too many input arguments error message. Is this what you are seeing, and if so, why did you not include this information in your question?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Gravitation, Cosmology & Astrophysics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!