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 .

 Réponse acceptée

Andreas Goser
Andreas Goser le 5 Mar 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 commentaires

Example from my installation:
>> which kmeans -all
C:\Program Files\MATLAB\R2013a\toolbox\stats\stats\kmeans.m
Image Analyst
Image Analyst le 5 Mar 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 le 6 Mar 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 le 7 Mar 2014
yes sir, you are right when i execute the above i am getting two different paths. thanks a lot sir.
chethan
chethan le 7 Mar 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 le 10 Mar 2014
The error message means KMEANS is unable to process UINT8.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by