To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
i used kmeans for clustering similar images.... if i run the code first i get the correct clusters..... but without closing matlab if i execute the second time for the same image, it is clustering different output.... why like that..... what shud i do to get the same output whenever i execute the code... please do reply.....
hi, i think this question has been asked before, the reason is that the K-means algorithm starts with random partition so every time you run the code, you get the same result but with different RMSE.
(try to clear the Workspace and re-run ...)
An option is to reset the random number generator to its initial state every time before running your code:
rng default % ->This is the important bit X = [randn(100,2)+ones(100,2);... randn(100,2)-ones(100,2)]; opts = statset('Display','final');
[idx,ctrs] = kmeans(X,2,... 'Distance','city',... 'Replicates',5,... 'Options',opts);
This will always produce the same result, but it sorts of beat the purpose of the function and might produce bad results.