sorry for the missing of the H1 line. It will be corrected in the next update.
Maybe you're also rigth with the elapsed time of the function. But this tool is prior created for older Matlab versions as 2009A and for little or medium size of data. Under these conditions, the function works sufficient fast and authentic and is much easier than others. Of course, for large data size you need tools which use Delaunay techniques to works fast and to avoid out of memory errors.
Thanks for your comment
- Computing the minimum distances for all pair of points is not a good way to compute nearest neighbor, and it's certainly not a fast one when the set of given points is large.
- As the author has warned, this method cannot handle large size data.
- The mfile miss the H1 line. When user type "help compute_nearest_neighbour' he/she would not know how to call the function, unless he is the author.
This function can accomplish with an equivalent stock function, which performs much faster. Here is the demo using new stock class in 2009A which is 10 time faster. For older Matlab version similar Delanay technique can be used to accomplish the same task as well.
n = 5000;
toc % Elapsed time is 0.322600 seconds.
toc % Elapsed time is 3.445318 seconds.