【发布时间】:2019-10-03 04:20:40
【问题描述】:
我试图在 Matlab 中绘制一条双曲线来模拟环绕地球的双曲线轨迹。
由于双曲方程由一个 +/- 部分(从平方根)组成,我似乎无法弄清楚如何让 Matlab 绘制它。
这是我目前的代码:
%Plotting Hyperbolic Orbit
e = 1.05; %Eccentricity
a = -147562.72; %km
b = abs(a)*sqrt(e.^2 -1); %Equation for Semi-Minor Axis, b
x1 = linspace(0.00001, a); %From 0 to a, Upper
x2 = linspace(-a, -0.00001); %From -a to 0, Lower
y1 = sqrt((b.^2)*((x1.^2)/(a.^2)-1)); %Upper Hyperbola Part
y2 = -sqrt((b.^2)*((x2.^2)/(a.^2)-1)); %Lower Hyperbola Part
figure
plot(x1, y1, x2, y2, 'b')
grid on
我最初尝试使用从 -a 到 a 的一个 x 坐标,但由于其中包含 0,它给了我一个虚数错误,最终无法绘制它。
感谢您的帮助。
【问题讨论】:
标签: matlab plot orbital-mechanics