i am unable to use KMEANS function

i am using matlab 2010b version and i am unable to use the KMEANS function in my programs. whenever i call the KMEANS function in my program i get the following error
  • * *??? Attempt to execute SCRIPT kmeans as a function:C:\Users\swathi.swathi-PC\Documents\MATLAB\kmeans.m
Error in ==> kmeans at 40 idx = kmeans ( x, k );* * * kindly help me out .

 Respuesta aceptada

Andreas Goser
Andreas Goser el 5 de Mzo. de 2014
Looks like you have multiple "kmeans" on the path.
which kmeans -all
Probably rename the kmeans.m from the path in your question?

7 comentarios

Example from my installation:
>> which kmeans -all
C:\Program Files\MATLAB\R2013a\toolbox\stats\stats\kmeans.m
Image Analyst
Image Analyst el 5 de Mzo. de 2014
And his is "C:\Users\swathi.swathi-PC\Documents\MATLAB\kmeans.m" so for sure, he wrote his own version that is being used in preference to the built in version.
chethan
chethan el 6 de Mzo. de 2014
sir can you please be a bit more elaborate on what you have mentioned above. can u brief me what i should do to overcome the error.
Execute
which kmeans -all
You likely will have more than one kmeans function. That causes this issue. It looks like you have created you own kmeans.m in C:\Users\swathi.swathi-PC\Documents\MATLAB\ and this one does different things than kmeans.m provided by MathWorks in the Statistics Toolbox.
chethan
chethan el 7 de Mzo. de 2014
yes sir, you are right when i execute the above i am getting two different paths. thanks a lot sir.
chethan
chethan el 7 de Mzo. de 2014
now the kmeans algorithm is working fine. but in one of my modules when i am executing the code i am getting the following error; ??? Error using ==> plus Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> kmeans>distfun at 723 D(:,i) = D(:,i) + (X(:,j) - C(i,j)).^2;
Error in ==> kmeans at 330 D = distfun(X, C, distance, 0);
Error in ==> test2 at 28 IDX = kmeans(uint8(ab(:,:,:)),3); i have passed the image to the kmeans function and i am getting the above error. kindly help me out.
Andreas Goser
Andreas Goser el 10 de Mzo. de 2014
The error message means KMEANS is unable to process UINT8.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 5 de Mzo. de 2014

Comentada:

el 10 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by