%% Configure Clustering Termination Conditions
% Load the clustering data.

load clusterdemo.dat

%
% Set the clustering termination conditions such that the optimization stops when either of the following occurs:
% The number of iterations reaches a maximum of 25.
% The objective function improves by less than 0.001 between two consecutive iterations.

options = [NaN 25 0.001 0];

% The first option is NaN, which sets the fuzzy partition matrix exponent to its default value of 2. Setting the fourth option to 0 suppresses the objective function display.
%
% Cluster the data.

[centers,U,objFun] = fcm(clusterdemo,3,options);

%
% To determine which termination condition stopped the clustering, view the objective function vector.

objFun

% The optimization stopped because the objective function improved by less than 0.001 between the final two iterations.
% Copyright 2015 The MathWorks, Inc.