MATLAB: How to find optimal k from k means clustering by using elbow method

k-means

I want to find optimal k from k means clustering by using elbow method . I have 100 customers and each customer contain 8689 data sets. How can I create a program to cluster this data set into appropriate k groups.

Best Answer

old question, but I just found a way myself looking at matlab documentation:
klist=2:n;%the number of clusters you want to try
myfunc = @(X,K)(kmeans(X, K));
eva = evalclusters(net.IW{1},myfunc,'CalinskiHarabasz','klist',klist)
classes=kmeans(net.IW{1},eva.OptimalK);
Related Question