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 回表示 (過去 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?
0 件のコメント
回答 (2 件)
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 件のコメント
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?
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!