How to use kmeans() function ??..

2 visualizaciones (últimos 30 días)
sani ars
sani ars el 2 de En. de 2013
Respondida: Puru el 13 de Nov. de 2015
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....

Respuestas (2)

Puru
Puru el 13 de Nov. de 2015
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 el 2 de En. de 2013
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