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 commentaires

Voss
Voss le 25 Mar 2022
Modifié(e) : Voss le 25 Mar 2022
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.
Hannah Beezie
Hannah Beezie le 25 Mar 2022
Thank you so much! That certainly looks more like the result I was aiming for.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Produits

Version

R2020b

Modifié(e) :

le 25 Mar 2022

Community Treasure Hunt

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

Start Hunting!

Translated by