MATLAB: Can not run a modified kmeans.m

kmeans modify error

I modified the original kmeans.m function in order to carry out certain experiment.I removed the part that handles empty cluster(s) and left other parts as they were.
The problem is at first I put the new kmeans_mod.m in my workspace and ran it, an error was reported saying 'undefined function statremovenan for input type single ….' (statremovenan is a function used in kmeans.m and I didn't have this error when I ran original kmeans.m). Then I thought maybe the script should be put in the toolbox/stat/stat/, so I did and ran again, this time another error was shown saying 'undefined function kmeans_mod for input type struct….', looks like the modified function was not recognised at all.
Any suggestion why would this happen and how to fix it? Thanks a lot!

Best Answer

rehash toolbox
after putting it in the appropriate toolbox directory