Obtain the input and output data.
load clusterdemo.dat
inputData = clusterdemo(:,1:2);
outputData = clusterdemo(:,3);
Create a genfisOptions option set for FCM Clustering, specifying a Mamdani FIS type.
opt = genfisOptions('FCMClustering','FISType','mamdani');
Specify the number of clusters.
opt.NumClusters = 3;
Suppress the display of iteration information to the Command Window.
opt.Verbose = 0;
Generate the FIS.
fis = genfis(inputData,outputData,opt);
The generated FIS contains one rule for each cluster.
showrule(fis)
ans = 3x83 char array
'1. If (in1 is in1cluster1) and (in2 is in2cluster1) then (out1 is out1cluster1) (1)'
'2. If (in1 is in1cluster2) and (in2 is in2cluster2) then (out1 is out1cluster2) (1)'
'3. If (in1 is in1cluster3) and (in2 is in2cluster3) then (out1 is out1cluster3) (1)'
Plot the input and output membership functions.
[x,mf] = plotmf(fis,'input',1);
subplot(3,1,1)
plot(x,mf)
xlabel('Membership Functions for Input 1')
[x,mf] = plotmf(fis,'input',2);
subplot(3,1,2)
plot(x,mf)
xlabel('Membership Functions for Input 2')
[x,mf] = plotmf(fis,'output',1);
subplot(3,1,3)
plot(x,mf)
xlabel('Membership Functions for Output')