Borrar filtros
Borrar filtros

k-means - missing to plot some data points

3 visualizaciones (últimos 30 días)
Berk
Berk el 21 de Abr. de 2013
I am using k-means to cluster 13 data points (X) into 3 clusters with the following code. However, when plotting the data points and cluster centers some of the data points disappear?
figure
mSize = 24;
hold on
X = [1 1;1 2;1 3;1 5;2 3;2 4;2 5;3 1;3 2;3 3;1 8;2 7;3 7]; % Data vector
[idx,ctrs] = kmeans(X,3); % cluster X into three clusters
plot(X(idx==1,1),X(idx==1,2),'r.','MarkerSize',mSize)
plot(X(idx==2,1),X(idx==2,2),'b.','MarkerSize',mSize)
plot(X(idx==3,1),X(idx==3,2),'k.','MarkerSize',mSize)
plot(ctrs(1,1),ctrs(1,2),'kx', 'MarkerSize',mSize,'LineWidth',2)
plot(ctrs(2,1),ctrs(2,2),'ko', 'MarkerSize',mSize,'LineWidth',2)
plot(ctrs(3,1),ctrs(3,2),'k^', 'MarkerSize',mSize,'LineWidth',2)

Respuesta aceptada

Tom Lane
Tom Lane el 22 de Abr. de 2013
I think they're just clipped at the boundary of the plot. Try adding this:
xlim([.9 3.1]); ylim([.9 8.1])

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by