Plotting Help (rocket motion around a planet

Hello! Currently I am trying to model the flight path of a rocket around the planet at various given velocities, however whenever I go to plot it just leaves me with a straight line, I know for a fact with the given conditions I have it should be a circle so I'm just wondering where I'm going wrong, and as always I appreciate the help and thank you for your time.
timespan = 0:0.0008:10;
Re = 6371;
IC = [5*Re 0 0 (sqrt((g*Re^2)/5*Re)/5*Re)];
options = odeset('reltol',1e-10,'abstol',1e-10);
g = 9.81;
[t,y] = ode45(@(t,y) planetmotion(t,y,g),timespan,IC,options)
r =y(:,1);
theta = y(:,3)
x = r.*cos(theta); y= r.*sin(theta);
plot(x,y);
axis equal ; xlabel('x,m'); ylabel('y,m');
function ydot = planetmotion(t,y,g)
Re = 6371;
r=y(1); rdot=y(2); theta=y(3); thetadot=y(4);
rddot = r*thetadot^2-g*(Re/r)^2;
thetaddot = -2*rdot*thetadot/r;
ydot = [rdot ; rddot ; thetadot ; thetaddot];
end
From how I've tweaked it so far I think my problem is within my initial condtions particularly the last component, but a fresh set of eyes is always helpful.

 採用された回答

Tristen Hernandez
Tristen Hernandez 2020 年 3 月 3 日

0 投票

Figured out problem,it was the last input for the initial condition like I thought.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by