%% Create Cascaded FIS Tree
% This example shows construction of a cascaded FIS tree. For more information on the types of fuzzy tree structures, see Fuzzy Trees.
% Create fuzzy systems fis1, fis2, fis3, and fis4, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis1.Inputs(1).Name = "dist_obs";
fis1.Inputs(2).Name = "angle_obs";
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis2.Inputs(1).Name = "dist_tar";
fis2.Inputs(2).Name = "angle_tar";
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);
fis4 = mamfis('Name','fis4','NumInputs',2,'NumOutputs',1);
fis4.Inputs(2).Name = "preheading_robot";
fis4.Outputs(1).Name = "heading_robot";

% Create a connection between output 1 of fis1 and input 1 of fis3.

con1 = ["fis1/output1" "fis3/input1"];

% Create a connection between output 1 of fis2 and input 2 of fis3.

con2 = ["fis2/output1" "fis3/input2"];

% Create a connection between output 1 of fis3 and input 1 of fis4.

con3 = ["fis3/output1" "fis4/input1"];

% Create the FIS tree.

casTree = fistree([fis1 fis2 fis3 fis4],[con1;con2;con3]);

% Display the inputs of the FIS tree.

casTree.Inputs

% Display the outputs of the FIS tree.

casTree.Outputs

% Copyright 2018 The MathWorks, Inc.