I am trying to plot an ellipse using a polarplot function.

조회 수: 21 (최근 30일)
Falak Mandali
Falak Mandali 2021년 9월 18일
댓글: Star Strider 2021년 9월 18일
I calculated the radii for every 1 degree increase in the angle from the major axis, and the calculation is right. But when I try to plot the points using a polar plot, I am getting a shaded region. I don't understand why that is happening and how to fix it. Your help is appreciated.
The following is my code:
%initialization
radius = zeros(1,361);
ta = linspace(0,360,361);
h_a = 450; %apogee height from Mars in km
e = 0.001; %eccentricity of ellipse
for i = 1:1:361 %true anamaly of the satellite as measure from the major axis of the ellipse poinint the perigee.
radius(i) = (h_a * (1 - e)) / (1 + (e .* cosd(ta(i))));
end
%plot
polarplot(ta, radius)
The following is the plot I got:

채택된 답변

Star Strider
Star Strider 2021년 9월 18일
The polarplot function requires the angular measure to be in radians.
Change that in the polarplot call and it works. (The elliptical nature can be made more apparent by temporarily increasing ‘e’ to be certain it is working as expected.)
%initialization
radius = zeros(1,361);
ta = linspace(0,360,361);
h_a = 450; %apogee height from Mars in km
e = 0.001; %eccentricity of ellipse
% e = 0.5;
for i = 1:numel(ta) %true anamaly of the satellite as measure from the major axis of the ellipse poinint the perigee.
radius(i) = (h_a * (1 - e)) / (1 + (e .* cosd(ta(i))));
end
%plot
polarplot(deg2rad(ta), radius)
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by