fcm模糊聚类matlab实例
时间: 2023-08-07 17:05:46
浏览: 122
以下是一个简单的 FCM 模糊聚类的 MATLAB 实例:
```matlab
% 生成随机数据
data = [randn(100,2)*0.75+ones(100,2);...
randn(100,2)*0.5-ones(100,2)];
% 设置模糊聚类的参数
num_clusters = 2;
options = [2.0, 100, 1e-5, 0];
% 进行 FCM 聚类
[centers, U] = fcm(data, num_clusters, options);
% 绘制聚类结果
figure;
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),'linestyle','none',...
'marker','*','color','g');
line(data(index2,1),data(index2,2),'linestyle','none',...
'marker','*','color','r');
plot(centers(1,1),centers(1,2),'x','color','k',...
'markersize',12,'linewidth',2);
plot(centers(2,1),centers(2,2),'x','color
```