1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 模糊C均值聚类算法matlab实现 FCMClust(模糊c均值聚类算法MATLAB实现)

模糊C均值聚类算法matlab实现 FCMClust(模糊c均值聚类算法MATLAB实现)

时间:2020-10-26 09:56:04

相关推荐

模糊C均值聚类算法matlab实现 FCMClust(模糊c均值聚类算法MATLAB实现)

function [center, U, obj_fcn] = FCMClust(data, cluster_n, options)

% FCMClust.m 采用模糊C均值对数据集data聚为cluster_n类

% 用法:

% 1. [center,U,obj_fcn] = FCMClust(Data,N_cluster,options);

% 2. [center,U,obj_fcn] = FCMClust(Data,N_cluster);

% 输入:

% data ---- nxm矩阵,表示n个样本,每个样本具有m的维特征值

% N_cluster ---- 标量,表示聚合中心数目,即类别数

% options ---- 4x1矩阵,其中

% options(1): 隶属度矩阵U的指数,>1 (缺省值: 2.0)

% options(2): 最大迭代次数(缺省值: 100)

% options(3): 隶属度最小变化量,迭代终止条件(缺省值: 1e-5)

% options(4): 每次迭代是否输出信息标志(缺省值: 1)

% 输出:

% center ---- 聚类中心

% U ---- 隶属度矩阵

% obj_fcn ---- 目标函数值

% Example:

% data = rand(100,2);

% [center,U,obj_fcn] = FCMClust(data,2);

% plot(data(:,1), data(:,2),'o');

% hold on;

% maxU = max(U);

% index1 = find(U(1,:) == maxU);

% index2 = find(U(2,:) == maxU);

% line(data(index1,1),data(index1,2),'marker','*','color','g');

% line(data(index2,1),data(index2,2),'marker','*','color','r');

% plot([center([1 2],1)],[center([1 2],2)],'*','color','k')

% hold off; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%

if nargin ~= 2 & nargin ~= 3, %判断输入参数个数只能是2个或3个

error('Too many or too few input arguments!');

end

data_n = size(data, 1); % 求出data的第一维(rows)数,即样本个数

in_n = size(data, 2); % 求出data的第二维(columns)数,即特征值长度

% 默认操作参数

default_options = [2; % 隶属度矩阵U的指数

100; % 最大迭代次数

1e-5; % 隶属度最小变化量,迭代终止条件

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。