%% Obtain Tunable Settings from FIS
% Create two fuzzy inference systems, and define the connection between the two.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = sugfis('Name','fis2','NumInputs',2,'NumOutputs',1);
con = ["fis1/output1" "fis2/input1"];

% Create a tree of fuzzy inference systems.

tree = fistree([fis1 fis2],con);

% Obtain the tunable settings of inputs, outputs, and rules of the fuzzy inference system.

[in,out,rule] = getTunableSettings(tree)

% You can use dot notation to specify tunable settings.
% For the first membership function of input 1:
% do not tune parameter 1,
% set the minimum ranges of the last two parameters to 0,
% and set the maximum ranges of the last two parameters to 1.

in(1).MembershipFunctions(1).Parameters.Free(1) = false;
in(1).MembershipFunctions(1).Parameters.Minimum(2:end) = 0;
in(1).MembershipFunctions(1).Parameters.Maximum(2:end) = 1;

% For the first rule:
% set input 1 membership function index non-tunable,
% allow NOT logic for input 2 membership function index,
% and do not ignore output 1 membership function index.

rule(1).Antecedent.Free(1) = false;
rule(1).Antecedent.AllowNot(2) = true;
rule(1).Consequent.AllowEmpty(1) = false;

% Copyright 2018 The MathWorks, Inc.