%% Create Type-2 Fuzzy Inference System from Data
% To create a type-2 FIS from input/output data, you must first create a type-1 FIS using genfis.
% Load training data and generate a FIS using subtractive clustering.

load clusterdemo.dat
inputData = clusterdemo(:,1:2);
outputData = clusterdemo(:,3);
opt = genfisOptions('SubtractiveClustering',...
                    'ClusterInfluenceRange',[0.5 0.25 0.3]);
fisT1 = genfis(inputData,outputData,opt);
fisT1.Outputs

%
% Convert the generated FIS to a type-2 FIS.

fisT2 = convertToType2(fisT1);

%
% Since the initial type-1 FIS is a Sugeno system, only the input MFs are converted to type-2 MFs.
% Copyright 2019 The MathWorks, Inc.