⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example_yf_fcmc1_01_.m

📁 模糊C均值聚类的一个参考材料,做模糊聚类是用的一个程序
💻 M
字号:
% ----------------------------------------------------------------------
% Example for testing Yf_FCMC1
% 
% ----------------------------------------------------------------------
% Written By: Mahdi Amiri.
% E-Mail: yashil1@yahoo.com
% Homepage: http://yashil.20m.com/
% June 2003
% ----------------------------------------------------------------------

% ----------------------------------------------------------------------
% Clean up
clc;
clear all;
close all;

% ----------------------------------------------------------------------
% Input data => Xin
Xin = Yf_SampleClusteringDataSets1 (30);
%Xin = Yf_SampleClusteringDataSets1 (11);
%Xin = Yf_SampleClusteringDataSets1 (12);
%load fcmdata.dat; Xin = fcmdata;

% ----------------------------------------------------------------------
% Plot input feature vectors
figure; plot(Xin(:,1),Xin(:,2),'o')
title ('Input feature vectors');

% ----------------------------------------------------------------------
% Number of clusters => nC
nC = 3;

% ----------------------------------------------------------------------
% Optional initial cluster centers
init_V = Xin(1:nC, :);

% ----------------------------------------------------------------------
% Call main function
%[V,U,E] = Yf_FCMC1 (Xin, nC);
[V,U,E] = Yf_FCMC1 (Xin, nC, [2; 100; 0.01; 1; 1], init_V);
%[V,U,E] = fcm(Xin, nC);

% ----------------------------------------------------------------------
% Display
V

% ----------------------------------------------------------------------
% Plot termination measure values
figure;
plot(E);
title ('Termination measure');
xlabel ('Iteration num.');
ylabel ('Termination measure value');

% ----------------------------------------------------------------------
% Plot clustered feature vectors
figure;
maxU = max(U);

cMarker = ['+' 'o' '*' '.' 'x' 's' 'd' '^' 'v' '>' '<' 'p' 'h'];
cColor =  ['r' 'g' 'b' 'm' 'c' 'y' 'k' 'r' 'g' 'b' 'y' 'm' 'c'];

for c = 1:nC
    index_c = find(U(c, :) == maxU);

    line(Xin(index_c, 1), Xin(index_c, 2), 'linestyle',...
        'none','marker', cMarker(c), 'color', cColor(c));
    
    hold on
    plot(V(c,1),V(c,2),['k' cMarker(c)],'markersize',15,'LineWidth',2)
end
title ('Clustered feature vectors');

% ----------------------------------------------------------------------
% Plot membership functions
figure; hold on;
subplot (nC, 1, 1)
plot (U(1, :), cColor(1))
title ('Membership functions');
for c = 2:nC
    subplot (nC, 1, c)
    plot (U(c, :), cColor(c))
end

% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -