MATLAB: How to find distance matrix using knnclassify in matlab

knn distance classification

I work in image classication and I used two classifiers : svm et knn. the problem is that the knnclassify matlab function allows only return a list of labels test images (class) and I need to get out the distance matrix
class = knnclassify( TestData , TrainData , TrainLabels);
please help me how can I find the distance matrix ?? and thanks in advance

Best Answer

You likely have to use knnsearch to get the distances. See the documentation on Classification Using Nearest Neighbors for details.
Related Question