MATLAB: Kmeans Too many input arguments.

kmeansoverloaded methodshadowed

Hello,
I know it asked multiple times but,alas I could not find solution so I decided to ask this. Iam looking the cluste only singe column data size(1,1)
[idx,C] = kmeans(data(:,3),2)
Error using kmeans
Too many input arguments.
  1. I get all the kmeans which kmeans -all and found 4. I believe C:\Program Files\MATLAB\R2018b\toolbox\stats\stats\kmeans.m is the correct one thats produce proper result but I could not figure out how can I make it work
  2. I go to home->set path (in environment section) and move it all the way top. But Iam getting still same error
  3. I found something str = who(which('kmeans')) bout only store the first one. Even if I store the shadowed one I do not know how can I make it work
  4. How can I remove the shadowed, as I understand if one function ishadowed it is not working
Is there a way to make work the 'wanted' kmeans, in this case it is the 3rd in the lists hadowed one.
I really appreciate the all answers
Many thanks in advance
which kmeans -all
Not on MATLAB path % kmeans constructor
C:\Program Files\MATLAB\R2018b\toolbox\stats\bigdata\@tall\kmeans.m % tall method
C:\Program Files\MATLAB\R2018b\toolbox\stats\gpu\@gpuArray\kmeans.m % gpuArray method
C:\Program Files\MATLAB\R2018b\toolbox\stats\stats\kmeans.m % Shadowed
C:\Users\zgrey\Desktop\mtex-5.1.1\tools\statistic_tools\kmeans.m % Shadowed kmeans constructor

Best Answer

Option 1
The best solution is to rename all of your custom kmeans() functions with unique names. Custom functions should generally have specific, unique names to avoid this problem.
Option 2
If option 1 isn't possible, try removing the conflicting functions from your path. You can see the path to the conflicting functions by using which functionName -all and then you can use rmpath() to remove the paths.
Option 3
A band-aid solution for built-in functions is to use the builtin() function which will execute the built-in function even if it is shadowed. Unfortunately kmeans() comes from a toolbox and is not built-in.
Option 4
For non built-in function that are shadowed, if you can't do options 1 or 2, you'll need to change the current directory to the directory that stores the shadowed function. Changing the cd isn't an optimal solution which is why this option is last. cd('path')