MATLAB: Kmeans

help me pleaseMATLAB

Hi there,
how to write the plot if i use 4 cluster like this:
X = [randn(100,2)+ones(100,2);… randn(100,2)-ones(100,2)]; opts = statset('Display','final'); [idx,ctrs] = kmeans(X,4,… 'Distance','city',… 'Replicates',5,… 'Options',opts); plot(X(idx==1,1),X(idx==1,2),'r.','MarkerSize',12) hold on plot(X(idx==2,1),X(idx==2,2),'b.','MarkerSize',12) [plot ….] [plot ….]
thank you

Best Answer

You do the same thing except:
plot(X(idx==1,1),X(idx==1,2),'r.','MarkerSize',10);
hold on
plot(X(idx==2,1),X(idx==2,2),'b.','MarkerSize',10);
plot(X(idx==3,1),X(idx==3,2),'g.','MarkerSize',10);
plot(X(idx==4,1),X(idx==4,2),'k.','MarkerSize',10);
Related Question