"too many output arguments" when using kmeans

1 回表示 (過去 30 日間)
Negar
Negar 2014 年 11 月 30 日
編集済み: Star Strider 2014 年 11 月 30 日
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

回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by