Want to connect 3D scattered data points with line

조회 수: 8 (최근 30일)
Todor Kereziev
Todor Kereziev 2021년 2월 24일
편집: darova 2021년 2월 26일
Hello guys,
I am trying to do a 3D scattered data plot and I want to conncet the points from the data with a line, I was able to do it but I am not sattisfied with the result. I dont want to connect the,m one after another, I want to connect point one with point two, then point one with point three and so on, I will insert a picture to make maybe more clear. And also I want to see the distance between two points, how its possible to do this?
Here is the code what I am using:
x = [264 260 293 241 280 259]
y = [264 335 333 318 310 349]; %%I am using the pixel value for Y each point
z = [70 21 27 9 1 53]; %I am using the pixel value for Z each point
figure
axis equal
scatter3(x,y,z, 'filled')
text (x(1),y(1),z(1),'Rot. Point');
text (x(2),y(2),z(2),'Center');
text (x(3),y(3),z(3),'Left');
text (x(4),y(4),z(4),'Right');
text (x(5),y(5),z(5),'Down');
text (x(6),y(6),z(6),'Up');
.

답변 (1개)

J. Alex Lee
J. Alex Lee 2021년 2월 25일
편집: J. Alex Lee 2021년 2월 25일
On way is to do it in a loop. After your code,
hold on
d = zeros(size(x)); % to hold distances from the first point
for i = 2:numel(x)
plot3(x([1,i]),y([1,i]),z([1,i]),'-k','LineWidth',2)
d(i) = sqrt((x(1)-x(i))^2+(y(1)-y(i))^2+(z(1)-z(i))^2)
end
  댓글 수: 1
Todor Kereziev
Todor Kereziev 2021년 2월 25일
Thank you!!!
It's exactly what I wanted to do, you are amazing, thank you so much!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by