Plotting Help (rocket motion around a planet
2 views (last 30 days)
Show older comments
Tristen Hernandez
on 3 Mar 2020
Answered: Tristen Hernandez
on 3 Mar 2020
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.
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!