I have a set of points (x, y) on the 2d plane. For the point (x0, y0) and the number k, we find the kth nearest neighbor (x0, x0) in the set of points. In detail, a set of points is represented by two arrays: x and y. The point (x0, y0) is given by the index i0. This means that x0 = x (i0) and y0 = y (i0).
Is there any function or something in Matlab this problem helps me. If Matlab does not have such a feature, can you suggest other effective ways.
EDIT : I need to calculate this kind of distance for each point (x0, y0) in the set. The set size is about 1000. The value of k should be around sqrt (1500). The worst part is that I do it many times. At each iteration, the set changes, and again I calculate the distances. Thus, runtime is a critical issue.
James do
source share