Plotting Trajectory in 3D From User Input

5 views (last 30 days)
autumn
autumn on 16 Aug 2019
Commented: darova on 17 Aug 2019
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 Comment
darova
darova on 17 Aug 2019
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

Sign in to comment.

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!