functionfcmeans - Data clustering using fuzzy c-means.
fcmeans find the c number of clusters in the data set Xin using fuzzy c-means algorithm. The centers for each cluster are returned in centers . U contains the grade of membership of each Xin point in each cluster. ofun is the last objetive function. ofunk is the objetive function in each iteration. em is the exit mode, if em is %t then the maximum number of iteration maxiter was reached, if em is %f then the minimum change between iteration epsilon was reached.
// Take 50 random pairs of points
Xin=rand(100,2);
// Find 7 clusters
[centers,U,ofun,ofunk]=fcmeans(Xin,7,2);
// Display information
xbasc();
subplot(2,2,1);
plot2d(Xin(:,1),Xin(:,2),-1,rect=[0 0 1 1]);
xtitle("Input pair of points","x","y");
subplot(2,2,3);
plot2d(centers(:,1),centers(:,2),-2,rect=[0 0 1 1]);
xtitle("Cluster centers","x","y");
subplot(2,2,2);
plot(ofunk);
xtitle("Objetive function in each iteration","k","ofun");
Jaime Urzua Grez