MATLAB: Different output in kmeans

clusteringStatistics and Machine Learning Toolbox

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…..

Best Answer

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 ...)