function [U_new, center, obj_fcn] = stepfcm(data, U, cluster_n, expo)
%STEPFCM One step in fuzzy c-mean clustering.
%	[U_NEW, CENTER, ERR] = STEPFCM(DATA, U, CLUSTER_N, EXPO)
%	performs one iteration of fuzzy c-mean clustering, where
%
%	DATA: matrix of data to be clustered. (Each row is a data point.)
%	U: partition matrix. (U(i,j) is the MF value of data j in cluster j.)
%	CLUSTER_N: number of clusters.
%	EXPO: exponent (> 1) for the partition matrix.
%	U_NEW: new partition matrix.
%	CENTER: center of clusters. (Each row is a center.)
%	ERR: objective function for parititon U.
%
%	Note that the situation of "singularity" (one of the data points is
%	exactly the same as one of the cluster centers) is not checked.
%	However, it hardly occurs in practice.
%
%       See also DISTFCM, INITFCM, IRISFCM, FCMDEMO, and FCM.

%	Roger Jang, 11-22-94.
%       Copyright (c) 1994-95  by The MathWorks, Inc.
%       $Revision: 1.5 $  $Date: 1995/02/17 13:08:10 $

mf = U.^expo;		% MF matrix after exponential modification
center = mf*data./((ones(size(data, 2), 1)*sum(mf'))');	% new center
dist = distfcm(center, data);		% fill the distance matrix
obj_fcn = sum(sum((dist.^2).*mf));	% objective function
tmp = dist.^(-2/(expo-1));		% calculate new U, suppose expo != 1
U_new = tmp./(ones(cluster_n, 1)*sum(tmp));
