Effacer les filtres
Effacer les filtres

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 vues (au cours des 30 derniers jours)
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?

Réponses (2)

Image Analyst
Image Analyst le 30 Juin 2014
Modifié(e) : Image Analyst le 30 Juin 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 commentaires
Akshit
Akshit le 1 Juil 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 ?!!?
Image Analyst
Image Analyst le 1 Juil 2014
So put it inside a loop over p and do that code for every point p. Why can't you do that?

Connectez-vous pour commenter.


Matt J
Matt J le 30 Juin 2014
See IPDM ( link )

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by