"too many output arguments" when using kmeans

1 Ansicht (letzte 30 Tage)
Negar
Negar am 30 Nov. 2014
Bearbeitet: Star Strider am 30 Nov. 2014
Hi all,
Im trying to cluster a set of data points using kmeans. but each time I receive the many output arguments error.I even tried to run the suggested example in MATLAB doc, but the same error appears: Too many output arguments. Im really wondering what the reason might be? Here is the sample code:
X = [randn(100,2)+ones(100,2);...
randn(100,2)-ones(100,2)];
opts = statset('Display','final');
[idx,ctrs] = kmeans(X,2,...
'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(ctrs(:,1),ctrs(:,2),'kx',...
'MarkerSize',12,'LineWidth',2)
plot(ctrs(:,1),ctrs(:,2),'ko',...
'MarkerSize',12,'LineWidth',2)
legend('Cluster 1','Cluster 2','Centroids',...
'Location','NW')
end

Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by