% This program illustrates how to upload tabular data (diabetes.dat),
% create K-means clusters, and plot graphs visualizing the clusters

clear; close

[X,varnames,casenames] = tblread('diabetes.dat', ',');

opts = statset('Display','final');

[idx,ctrs] = kmeans(X,2);

%% To create a scarterplot of the clusters use:
gplotmatrix(X,X,idx,[],[],[],[],[],varnames,varnames);


%% for a different value of k (e.g., 3), simply change the clustering
%% instruction above to: 
%% [idx,ctrs] = kmeans(X,3);
