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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (2)
Image Analyst
el 30 de Jun. de 2014
Editada: Image Analyst
el 30 de Jun. de 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 comentarios
Image Analyst
el 1 de Jul. de 2014
So put it inside a loop over p and do that code for every point p. Why can't you do that?
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!