Matlab:K-means clustering

cluster-analysis, k-means, machine-learning, matlab

Solution

I can't think of a better way to do it than what you described. A built-in function would save one line, but I couldn't find one. Here's the code I would use:

[ids ctrs]=kmeans(A,19);
D = dist([testpoint;ctrs]); %testpoint is 1x10 and D will be 20x20
[distance testpointID] = min(D(1,2:end));

Problem

I have a matrice of A(369x10) which I want to cluster in 19 clusters. I use this method ``` [idx ctrs]=kmeans(A,19) ``` which yields idx(369x1) and ctrs(19x10) I get the point up to here.All my rows in A is clustered in 19 clusters. Now I have an array B(49x10).I want to know where the rows of this B corresponds in the among given 19 clusters. How is it possible in MATLAB? Thank you in advance

Original source