?? example_yf_fcmc1_01_.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 + -