Group: | Matrix Manipulation |
Topic: | Sorting and Counting |
See also: | knn |
Function: | mknn | |
Description: | mknn gives an array containing the indices of the k nearest neighbors of each element in matrix y with respect to x. The parameter y is optional, if it is not given, x will be taken for y. As a measure of distance the squared euclidean distance is used. |
Usage: | z = mknn (x, k{, y}) | |
Input: | ||
y | m x p x d1 x ... x dn array | |
x | n x p x d1 x ... x dn array | |
k | scalar (number of neighbors) | |
Output: | ||
z | m x k x d1 x ... x dn array |
x=1:4 y=2:5 mknn(x,3,y)
Contents of mknn [1,] 2 1 3 [2,] 3 2 4 [3,] 4 3 2 [4,] 4 3 2