%% Generate FIS Using Grid Partitioning
% Define training data.

inputData = [rand(10,1) 10*rand(10,1)-5];
outputData = rand(10,1);

%
% Create a default genfisOptions option set for grid partitioning.

opt = genfisOptions('GridPartition');

%
% Specify the following input membership functions for the generated FIS:
% 3 Gaussian membership functions for the first input variable
% 5 triangular membership functions for the second input variable

opt.NumMembershipFunctions = [3 5];
opt.InputMembershipFunctionType = ["gaussmf" "trimf"];

%
% Generate the FIS.

fis = genfis(inputData,outputData,opt);

%
% Plot the input membership functions. Each input variable has the specified number and type of input membership functions, evenly distributed over their input range.

[x,mf] = plotmf(fis,'input',1);
subplot(2,1,1)
plot(x,mf)
xlabel('input 1 (gaussmf)')
[x,mf] = plotmf(fis,'input',2);
subplot(2,1,2)
plot(x,mf)
xlabel('input 2 (trimf)')

% Copyright 2012 The MathWorks, Inc.