After sending the email below, I found that:
d=dist(X,C')
accomplish the same thing like pdist2 mentioned below.
Am I right here?
Thanks, Tom for the help.
"Tom Lane" <tlane@mathworks.nospam.com> wrote in message <j509bo$bhi$1@newscl01ah.mathworks.com>...
> > [IDX,C] = kmeans(M,10) > Getting my centroid location in C with k=10
> ...
> > [IDX,C,sumd,D] = kmeans(X,10)
> > then my C (or the centroid location) will change.
>
> Fred, it sounds like you want to compute C from M, then just assign points
> in X to one of the C rows based on the distance  not do any reclustering.
> I think you just want to compute the distances and find the minimum
> directly. Try this:
>
> x = [rand(5,2);1+rand(5,2)]; % some data
> c = [.5 .5; 1.5 1.5]; % the cluster centroids I want
> d = pdist2(x,c); % compute distances from each point to each centroid
> [~,cc] = min(d,[],2); % get the centroid that achieves the minimum
>
>  Tom
