'How do I find the 20 nearest neighbors for the first 100 instances to the mean of each class in this 256x1100x10 uint8 dataset using Matlab?

This is the code I have so far. I want to use the Matlab function fitcknn to accomplish this but don't know where to start

clear, clc
load('usps_all.mat')
averaged_by_class_data=mean(data,2) %mean of each class - there are 10 classes

for class=1:10
    first_100_images=data(:,1:100,class)
    Mdl = fitcknn(averaged_by_class_data(:,:,class),first_100_images,'NumNeighbors',20,'Standardize',1)
    
end


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source