K- Means clustering problem

Hello Everyone,
I have a small problem with clustering. I don't know if someone can help me with, i want to plot the graph of points and the centroids when i am using k-means clustering on the vector y = [ 2 4 5 6 7 8 1 1 3 4] and k=3 i am using the following commands:
n= [1:10]
y = [ 2 4 5 6 7 8 1 1 3 4]
plot(n, y, '*')
--those are the points i want to partition between the 3 clusters--
[p o]=kmeans(y,3)
plot(y(1,p==1),'r.')
plot(y(1,p==2),'b.')
plot(o(1,:),o(2,:),'kx')
plot(o(1,:),o(2,:),'ko')

답변 (1개)

Tom Lane
Tom Lane 2013년 4월 22일

0 개 추천

Try "help hold" to see how to make plotting commands stop overwriting previous figure contents.

카테고리

도움말 센터File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

질문:

2013년 4월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by