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?

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