function label = knnr(sampledata, testdata, k) % KNNR K-nearest neighbor rule for classification % LABEL = KNNR(SAMPLE, INPUT, K) % SAMPLE: data set (last column: desired class) % INPUT: input (feature) matrix, with each row being the values % of a specific feature % K: the "k" in k nearest neighbor % LABEL: KNNR output % % Note that the output label of the SAMPLE is assumed to take % the values from 1 to n, where n is the number of classes.