필터 지우기
필터 지우기

I have a set of 3D points (x,y,z) , I want to take each point and calculate the sum of distances from all other points from this point and find the minimum of it , could you help me with codes?

조회 수: 2 (최근 30일)
I have a set of 3D points (x,y,z) , I want to take each point and calculate the sum of distances from all other points from this point and find the minimum of it , could you help me with codes?

답변 (2개)

Image Analyst
Image Analyst 2014년 6월 30일
편집: Image Analyst 2014년 6월 30일
Did you try this:
distances = sqrt((xp - xyz(:,1))^2 + (yp - xyz(:,2))^2 + (zp - xyz(:,3))^2);
sumOfDistances = sum(distances);
[minDistance, indexOfMin] = min(distances);
where (xp, yp, zp) is the single point, and xyz is the array of all points?
  댓글 수: 2
Akshit
Akshit 2014년 7월 1일
I think it does not work , because I want to try this for all of points (I mean (xp,yp,zp) is changing inside arrays ?!!?
Image Analyst
Image Analyst 2014년 7월 1일
So put it inside a loop over p and do that code for every point p. Why can't you do that?

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


Matt J
Matt J 2014년 6월 30일
See IPDM ( link )

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by