error Attempt to execute SCRIPT kmeans as a function:

25 ビュー (過去 30 日間)
Marcella Dayrell
Marcella Dayrell 2020 年 11 月 10 日
編集済み: Stephan 2020 年 11 月 10 日
Attempt to execute SCRIPT kmeans as a function:
C:\Users\........\kmeans.m
Error in kmeans (line 18)
[idx, centers sum, dist] = kmeans(data(:,1:4), 3, 'MaxIter', i);
How can I solve this?

回答 (1 件)

Stephan
Stephan 2020 年 11 月 10 日
編集済み: Stephan 2020 年 11 月 10 日
Rename your script. kmeans is an inbuild function, which is shadowed by your script. In general script names should not be named ike inbuild functions to avoid problems.
which kmeans -al
should not result in something like this:
>> which kmeans -all
C:\Users\ABCDE\Projects\kmeans.m
C:\Program Files\MATLAB\R2020a\toolbox\stats\bigdata\@tall\kmeans.m % tall method
C:\Program Files\MATLAB\R2020a\toolbox\stats\gpu\@gpuArray\kmeans.m % gpuArray method
C:\Program Files\MATLAB\R2020a\toolbox\stats\stats\kmeans.m % Shadowed
If there are also results from your script folder, you know there is a problem.

Community Treasure Hunt

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

Start Hunting!

Translated by