%% Generate Sugeno-Type FIS and Specify Number of Clusters
% Obtain the input and output data.

Xin = [7*rand(50,1) 20*rand(50,1)-10];
Xout = 5*rand(50,1);

%
% Create a genfisOptions|option set for FCM Clustering. By default FIS type, |opt.FISType, is 'sugeno'.

opt = genfisOptions('FCMClustering');

%
% Specify the number of clusters.

opt.NumClusters = 3;

%
% Suppress the display of iteration information to the Command Window.

opt.Verbose = 0;

%
% Generate the FIS.

fismat = genfis(Xin,Xout,opt);

% To see the contents of fismat, use FIS object interfaces, e.g. fismat.Inputs, fismat.Outputs, and fismat.Rules.
%
% Plot the input membership functions.

[x,mf] = plotmf(fismat,'input',1);
subplot(2,1,1), plot(x,mf)
xlabel('Membership Functions for Input 1')
[x,mf] = plotmf(fismat,'input',2);
subplot(2,1,2), plot(x,mf)
xlabel('Membership Functions for Input 2')

% Copyright 2012-2019 The MathWorks, Inc.