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 .

 채택된 답변

Andreas Goser
Andreas Goser 2014년 3월 5일

0 개 추천

Looks like you have multiple "kmeans" on the path.
which kmeans -all
Probably rename the kmeans.m from the path in your question?

댓글 수: 7

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

질문:

2014년 3월 5일

댓글:

2014년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by