
plotting a joining line between points in simulation.
3 次查看(过去 30 天)
显示 更早的评论
I am in the middle of a simulation of planetary orbits. I am using Euler integration for Newtons law of universal gravity and have inputted the numbers for Earth's and venus' orbit (simulating the two body problem). I am plotting the position of the planets as well as a trail behind them (the trail always consists of the last twenty points). However I would like to plot the orbit of Earth (and other planets) under the influence of the other planet against Earth's orbit only influenced by the Sun. The problem that I have is that in order to illustrate the difference in the two orbits I want to plot a line joining the two points. How do I do this?
0 个评论
回答(1 个)
Star Strider
2015-12-26
I’m not sure I’m understanding ‘a line joining the two points’. If you want lines connecting corresponding points (for example with respect to time) between the two orbits, this will work:
t = linspace(0, 2*pi, 100); % Time Parameter
Re = 1.5E8; % Mean Earth Orbit Radius (km)
eu_xy = [Re*cos(t); Re*sin(t)]; % Unperturbed Orbit (Created)
ep_xy = [1.1*Re*cos(t); 1.05*Re*sin(t)]; % Perturbed Orbit (Created)
figure(1)
plot(eu_xy(1,:), eu_xy(2,:)) % Plot Unperturbed Earth Orbit
hold on
plot(ep_xy(1,:), ep_xy(2,:)) % Plot Perturbed Earth Orbit
plot([eu_xy(1,:); ep_xy(1,:)], [eu_xy(2,:); ep_xy(2,:)]) % Plot Lines Between Parametrically Similar Points
hold off
The formats of the orbit calculations ‘eu_xy’ and ‘ep_xy’ are straightforward. To plot the corresponding time points between the two orbits, plot the x-values of both in one matrix against the y-values of both in the other. The result is this plot:

I have no idea what your orbits actually look like so I just guessed. This approach should work, regardless. (I tested it with a few other aberrant orbits that crossed the unperturbed orbit and it worked also.) If you have problems getting it to work with your data, let me know and I will help you get the problem sorted.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Earth and Planetary Science 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!