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?

1 visualizzazione (ultimi 30 giorni)
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?

Risposte (2)

Image Analyst
Image Analyst il 30 Giu 2014
Modificato: Image Analyst il 30 Giu 2014
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 Commenti
Akshit
Akshit il 1 Lug 2014
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 ?!!?

Accedi per commentare.


Matt J
Matt J il 30 Giu 2014
See IPDM ( link )

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by