MATLAB: How to let function ‘kmeans’ run reliably

kmeans

I am trying to cluster data. The data variable is 'DailyValue'. The dimension of it is 367*48. I use a for loop to run 'kmeans' for each column. The group number K I set is 9. Sometimes, kmeans returned results. Othertimes, I was given Error message like:
[idx c] = kmeans(DailyValue(:,1),9); Error using kmeans/loopBody/batchUpdate (line 453) Empty cluster created at iteration 1.
Error in kmeans/loopBody (line 378) converged = batchUpdate();
Error in internal.stats.parallel.smartForReduce (line 128) reduce = loopbody(iter, S);
Error in kmeans (line 296) ClusterBest = internal.stats.parallel.smartForReduce(…
Anyone can solve it, please?

Best Answer

Look at the documentation page, at the 'emptyaction' option.