 |
machine learning - Matlab:K-means clustering - Stack Overflow
Assuming you're using squared euclidean distance metric, try this: for i = 1:size(ctrs,2) d(:,i) = sum((B-ctrs(repmat(i,size(B,1),1),:)).^2,2); end [distances,predicted] = min(d,[],2) predicted should then contain the index of the closest centroid, and di
stackoverflow.com |
 |