kmeans is suddenly behaving differently
1 view (last 30 days)
Show older comments
Dear Matlab-Community,
just a few days ago I built a skript that required clustering and used the function kmeans(Data,Clusters,Options) and it worked straight away and I got good results with the following settings, analog to a setup from the examples:
opts = statset('Display','final');
[idx1, C1] = kmeans(2,datZ,'Distance','sqeuclidean','Replicates',5,'Options',opts);
Today, if I run the same script I get: Error using kmeans Too many input arguments."
The help for kmeans also returns a different function (?!) now:
kmeans Trains a k means cluster model.
Description
CENTRES = kmeans(CENTRES, DATA, OPTIONS) uses the batch K-means
algorithm to set the centres of a cluster model. The matrix DATA
represents the data which is being clustered, with each row
corresponding to a vector. The sum of squares error function is used.
The point at which a local minimum is achieved is returned as
CENTRES. The error value at that point is returned in OPTIONS(8).
Did the function get updated and change its functionality? Does anyone know what is going on?
If I then try to adapt to the suggestion from the help I get:
Error using kmeans (line 46)
Data dimension does not match dimension of
centres
/Update: This only occurs in R2017a and not in R2016b! kmeans works like expecter kmeans(Data,Clusters,...) like expected. The Bug/Issue is only found in R2017a.
0 Comments
Accepted Answer
Jan
on 21 Jun 2017
Edited: Jan
on 21 Jun 2017
This means that you have installed the FEX: NETLAB toolbox written by Ian T. Nabney, which contains a kmeans function also. Obviously it was inserted on top of the Matlab path, such that builtin functions are shadowed. You can check this by:
which kmeans -all
5 Comments
Jan
on 22 Jun 2017
@Maximilian: No, Matlab does not modify the path by its own. You could do this temporarily by addpath and as long as the new path is not stored by savepath, teh changes vanish with a restart.
If the pathdef.m file was made writable for users, another user of your machine might have changed the path there. This would be evil and modifying matlabroot\toolbox\local\pathdef.m should be forbidden on multi-user machines.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!