Fuzzy Logic Toolbox | ![]() ![]() |
Syntax
Description
[center, U, obj_fcn] = fcm(data, cluster_n)
applies the fuzzy c-means clustering method to a given data set.
The input arguments of this function are:
data
: data set to be clustered; each row is a sample data point
cluster_n
: number of clusters (greater than one)
The output arguments of this function are:
center
: matrix of final cluster centers where each row provides the center coordinates
U
: final fuzzy partition matrix (or membership function matrix)
obj_fcn
: values of the objective function during iterations
fcm(data,cluster_n,options)
uses an additional argument variable, options
, to control clustering parameters, introduce a stopping criteria, and/or set the iteration information display.
options(1)
: exponent for the partition matrix U
(default: 2.0)
options(2)
: maximum number of iterations (default: 100)
If any entry of options
is NaN,
the default value for that option is used instead. The clustering process stops when the maximum number of iterations is reached, or when the objective function improvement between two consecutive iterations is less than the minimum amount of improvement specified.
Examples
data = rand(100, 2); [center,U,obj_fcn] = fcm(data, 2); plot(data(:,1), data(:,2),'o'); maxU = max(U); index1 = find(U(1,:) == maxU); index2 = find(U(2, :) == maxU); line(data(index1,1), data(index1, 2), 'linestyle', 'none', 'marker', '*', 'color', 'g'); line(data(index2,1), data(index2, 2), 'linestyle', 'none', 'marker', '*', 'color', 'r');
![]() | evalmf | findcluster | ![]() |