3

How can I find the nearest points of two set of 3D points(with different number,set1 includes 400 points and set2 includes 2000 points) and then find the Euclidean distance between set1 and result from first part of the question?

1
  • share your code... hint is using knnsearch and pdist2
    – Autonomous
    Feb 26, 2013 at 16:36

2 Answers 2

2

You can use pdist2 to compute all distances and then pick the minimal distance.

allDist = squareform( pdist2( set1, set2 ) );
[minDist nni] = min( allDist, [], 2 ); 

Now minDist holds the minimal distance of each point in set1 to its nearest-neighbor (set2(nni)).

EDIT:
for low dimensional points (3 in this example) it should be more efficient to look at k-NN algorithms, as proposed in my other answer.

0

Have you considered using k-Nearest Neighbors (kNN) search?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.