Plotting Trajectory in 3D From User Input

7 次查看(过去 30 天)
Hi! I'm trying to plot a trajectory on a globe (that I have already built) using an input window. The code for that is below.
prompt = {'Enter start x-coordinate (ECF).',...
'Enter start y-coordinate (ECF).',...
'Enter start z-coordinate (ECF).',...
'Enter end x-coordinate (ECF).',...
'Enter end y-coordinate (ECF).',...
'Enter end z-coordinate (ECF).'};
dlgtitle = 'Custom Trajectory';
dims = [1 35];
definput = {'4.89e6','-4.27e4','4.08e6',...
'5.11e6','1.53e6','4.69e6'};
answer = inputdlg(prompt,dlgtitle,dims,definput);
As you can see, there are values for the starting point and ending point that the user can input. Of course, I want the entire trajectory. Is there any way to increment between the starting and ending points and plot them from a window like this? I hope I explained this well enough. Thank you!
  1 个评论
darova
darova 2019-8-17
What if point are not on the sphere?
S = str2double(answer(1:3));
E = str2double(answer(4:6));
[X,Y,Z]= sphere();
R = norm(S);
surf(R*X,R*Y,R*Z,'EdgeColor','none')
hold on
plot3([S(1) E(1)], [S(2) E(2)], [S(3) E(3)],'.-b')
hold off
axis equal
img111.png

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by