Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

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

Example:
x=1:4
y=2:5
mknn(x,3,y)

Result:
Contents of mknn

[1,]     2     1     3
[2,]     3     2     4
[3,]     4     3     2
[4,]     4     3     2



(C) MD*TECH Method and Data Technologies, 05.02.2006