How to use kmeans() function ??..

3 vues (au cours des 30 derniers jours)
sani ars
sani ars le 2 Jan 2013
Réponse apportée : Puru le 13 Nov 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....

Réponses (2)

Puru
Puru le 13 Nov 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 le 2 Jan 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