How to plot circles in polar form?

I am attempting to plot the orbits of the planets in polar form using matricies holding the relevant values.
When attempting to use the polarplot() function, the resulting graph does not produce any circles/ellipses, only a few connected line segments.
What might I have done incorrectly in attempting to graph these orbits?
Please DO NOT suggest any changes that use a non-vectorized method.
My current code (reduced to only 4 planets for demonstration):
p = [.387 .723 1 1.524];
E = [.2056 .0068 .0167 .0934];
theta = deg2rad([7.005 3.3947 0 1.851]);
radius = p./(1.- (E.*cos(theta)));
polarplot(theta, radius);

2 Comments

You've only got four points there, when you need four orbits, right?
I don't know enough about equations for elliptical orbits to know where your theta are supposed to fit in, but I know that you'll have to specify points all the way around the orbit:
p = [.387 .723 1 1.524];
E = [.2056 .0068 .0167 .0934];
% theta = deg2rad([7.005 3.3947 0 1.851]);
theta = linspace(0,2*pi,100).';
radius = p./(1 + (E.*cos(theta)));
polarplot(theta, radius,'LineWidth',2);
That gives you some orbits; maybe you can work with it to get what you're going for.
Thank you so much! That certainly looks more like the result I was aiming for.

Sign in to comment.

Answers (0)

Categories

Find more on Earth and Planetary Science in Help Center and File Exchange

Products

Release

R2020b

Asked:

on 25 Mar 2022

Edited:

on 25 Mar 2022

Community Treasure Hunt

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

Start Hunting!