Correcting the label in a 3D scatter plot

1 view (last 30 days)
Hello there,
I have a .xls file that contains x,y,z vertics. The sequence goes something like this (that header of each): x0,y0,z0,x1,y2,z2,..........x1000,y1000,z1000. (3000points in total) Each x,y,z together forms a point I see in the scatter 3D point. I am wondering how to identity/access that particular point properly, say x0,y0,z0 will be verticx 0, x1000,y1000,z1000 will be verticx 1000.
That's what I have from the help eailer:
clc;clear all;
[num,txt,raw] = xlsread('test_april24.csv');
for i = 1:3:3000
a = num(3,i);
b = num(3,i+1);
c = num(3,i+2);
k=scatter3(a,b,c, 'filled');
S=string(1:3000).';
text(a, b, c, S);
row = dataTipTextRow('Index: ',i');
k.DataTipTemplate.DataTipRows(end+1) = row;
hold on
end
The index number is now just showing one of the axis (since its based on the total number i) say index 3000 but I am expecting 1000
In addition, when the index popped up, is there a way that I can access a participant point that I am interested? say x100,y100,z100 (verticx100)?
Many thanks!
  5 Comments
steamrice
steamrice on 26 Apr 2020
Sorry I uploaded the .csv one now
steamrice
steamrice on 26 Apr 2020
Are you able to open that? @darova
Thanks

Sign in to comment.

Accepted Answer

darova
darova on 27 Apr 2020
I used currentPoint property of callback to get coordinates of mouseclick
currentPoint returns 2 points in 3D space. I used crossp roduct to find closest point
See script inside
  8 Comments
steamrice
steamrice on 27 Apr 2020
No problem! Thanks for the suggestions here.
That's what I was trying to achieve there. If you don't mind ask a follow up question, is the vertex that I see here corresponding to the header of the excel? I am wondering is there a way for me to verifiy this? Like if click vertex 1, would it be able to show its x,y,z component so I can go back to the excel/ text file to verfiy that?
darova
darova on 27 Apr 2020
Sure. Go inside callback function and add this line
% line(x(ix),y(ix),z(ix),'marker','*')
[x(ix) y(ix) z(ix)]

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 27 Apr 2020
If you want vertex 100, just use that index to get the x, y, and z values:
x100 = x(100);
y100 = y(100);
z100 = z(100);
  7 Comments
steamrice
steamrice on 27 Apr 2020
Does that mean more sense.. Thanks!
Image Analyst
Image Analyst on 27 Apr 2020
No, but it looks like darova figured out what you want and solved it because you accepted his/her answer.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!