Help Graphing a Parabola

I'm doing a project for orbital mechanics and I'm stuck on graphing a parabola using parametric equations. I think I know the what the problem is: I need it to graph the trajectory of the parabolic orbit, but I'm adding a value so large the function doesn't graph like a parabola should. Any help on how I can correctly graph this?
if true
% code
end
if
r_p=1.275620000225780e04;
a=-1.019309762925967e11;
Re=6.378e3;
q=-(r_p+a);
q2=q+a;
T=[-20000*pi,20000*pi];
x_graph=(-1*(T.^2))+q;
y_graph=T;
plot(x_graph,y_graph,'b');
hold on
hold on
grid on
plot(q,0,'ro') %center of the earth
plot(Re*cos(T)+q,Re*sin(T),'--') %plots the surface of the earth
hold on
% hold on
% lineseg([q 0], PeriVect_new)
% lineseg([q 0],PeriVect_OG)
% hold off
hold off
hold off
hold off
end

3 Comments

You define 2 points also. How could this create a parabola?
What are you talking about? The point defined appears on the plot, it has nothing to do with the formation of the parabola.
Jan
Jan on 2 Oct 2017
Edited: Jan on 2 Oct 2017
See my answer.

Sign in to comment.

Answers (1)

Jan
Jan on 2 Oct 2017
Edited: Jan on 2 Oct 2017
T is a [1 x 2] vector. Then x_graph and y_graph have 2 elements also. With these two points, you can either draw 2 points or a line, but not a parabola. See your code:
r_p = 1.275620000225780e04;
a = -1.019309762925967e11;
Re = 6.378e3;
q = -(r_p+a);
q2 = q + a;
T = [-20000*pi,20000*pi];
x_graph = (-1*(T.^2))+q;
y_graph = T;
disp(x_graph)
disp(y_graph)
Perhaps you want:
T = linspace(-20000*pi, 20000*pi, 1000);
x_graph = (-1*(T.^2))+q;
y_graph = T;
plot(x_graph,y_graph,'b');

Categories

Find more on Gravitation, Cosmology & Astrophysics in Help Center and File Exchange

Asked:

on 2 Oct 2017

Edited:

Jan
on 2 Oct 2017

Community Treasure Hunt

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

Start Hunting!