How to plot multiple functions on one graph>
显示 更早的评论
I need to plot the orbits of four different planets on the same graph in Matlab. The code below works for each plot individually, creating the orbit plot that I want. However, when I put all the codes together like I do below, I get a plot that looks like 4 straight lines going in random directions.
ro=[0,0,1.50e11];
vo=[0,2*pi*ro(3)/(365*24*60*60),0];
for n=1:730
delt_t=24*60*60
[r,v]= orbits3d(ro,vo,delt_t)
plot3(r(1),r(2),r(3), 'go')
hold on
ro=r
vo=v
end
ro=[0,0,2.28e11];
vo=[2*pi*ro(2)/(365*24*60*60*1.88),0,0];
for n=0:1:730*1.88
delt_t=24*60*60
[r,v]= orbits3d(ro,vo,delt_t)
plot3(r(1),r(2),r(3), 'ro')
hold on
ro=r
vo=v
end
ro=[0,0.58e11,0];
vo=[2*pi*ro(1)/(365*24*60*60*0.241),0,0];
for n=1:730*.241
delt_t=24*60*60
[r,v]= orbits3d(ro,vo,delt_t)
plot3(r(1),r(2),r(3), 'bo')
hold on
ro=r
vo=v
end
ro=[0,1.08e11,0];
vo=[0,0,2*pi*ro(3)/(365*24*60*60*0.615)];
for n=1:730*.615
delt_t=24*60*60
[r,v]= orbits3d(ro,vo,delt_t)
plot3(r(1),r(2),r(3), 'mo')
hold on
ro=r
vo=v
end
How can I make it so each orbit appears on the graph without affecting the other graphs?
Thanks
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!