image thumbnail


version (1.71 KB) by Andreas Richter
This function compute the nearest neighbours by Euclidean distance.


Updated 14 Jul 2009

View License

This function compute the nearest neighbours (by Euclidean distance) to a set of given points from a set of candidate points.
In this tool, exclusively the really nearest point will be calculated
without using special algorithms (delaunay, brute search etc. ) and also without a loop. Therefore, the function is very fast but
supports only a limited set of canditate and given points in 3D. For very large input data it can be lead to out of memory errors because the maximum adressable memory area of 32-Bit operation systems is located about 2 GByte (or 3 GByte with a change in the boot of the windows operation system).


an N1 x 3 matrix of cantitate_points
an N2 x 3 matrix of given_points (N1 and N2 can be different)


an N2 x 1 matrix (column) with the numbers of the nearest neighbour points to each canditate point. (The number of a row in the nearest neighbour matrix is equivalent to the number of the given point in the canditate points matrix)

Cite As

Andreas Richter (2021). nearest_neighbour_3D (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!