How to use kmeans() function ??..

조회 수: 3 (최근 30일)
sani ars
sani ars 2013년 1월 2일
답변: Puru 2015년 11월 13일
I am using kmeans() function as follows:
x = [1 2 3 7 3; 4 5 6 9 2; 7 8 9 12 3; 10 11 12 8 1; 13 14 15 12 7]
tdata = kmeans(x,3)
it is giving me following error:
Error using kmeans (line 46)
Data dimension does not match dimension of centres
Then I tried to do it as:
x = [1 2 3 7 3; 4 5 6 9 2; 7 8 9 12 3; 10 11 12 8 1; 13 14 15 12 7]
opts = statset('Display','final');
>> [idx,ctrs] = kmeans(X,2,...
'Distance','city',...
'Replicates',5,...
'Options',opts);
it is giving error as:
Error using kmeans
Too many input arguments.
I am unable to find where is the mistake.... I did the same as given in example in help.... Then why I am unable to do clustering??...
plz do guide me to figure it out and fix it....

답변 (2개)

Puru
Puru 2015년 11월 13일
I had a similar problem. I tried using
which -all kmeans
and realised that there is the same function in "netlab" tool box, which was shadowing the "stats" toolbox "kmeans" function (the one I needed to use).
So i went to "set path" window (it should be in "home" menu), and removed the netlab from the directory (alternate way would be to move it below stats toolbox).
And it worked!!

Walter Roberson
Walter Roberson 2013년 1월 2일
Please use
which -all kmeans
to check whether you have accidentally introduced another kmeans function.
Which MATLAB version are you using?

Community Treasure Hunt

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

Start Hunting!

Translated by