function U = mfuhcm(center,data,dij)
%Determine the membership matrix U of hard C-means

%Carson KAO, May 12, 1997

U = zeros(size(center,1),size(data,1));
min_dij = dij - (ones(size(dij,1),1)*min(dij));	%find minimum dij
index_U = find(min_dij == 0);
U(index_U) = ones(size(index_U,1),1);		%set Uij=1 on minimum dij
if sum(sum(U)) ~= size(U,2),	%check if 2,3.. min dij on the same column 
   index_Ucol = find(sum(U) ~= 1);
   for m = 1:length(index_Ucol),
       index_Urow = min(find(U(:,index_Ucol(m)) == 1));
       tmp_U = zeros(size(U,1),1);
       tmp_U(index_Urow) = 1;
       U(:,index_Ucol(m)) = tmp_U;
   end
end 				%end if