%% Update FIS Tree Outputs
% This example shows how to add or remove FIS tree outputs.
%% Add Outputs
% Create fis1, fis2, and fis3, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);

% 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 the FIS tree.

fuzzTree = fistree([fis1 fis2 fis3],[con1;con2]);

%  Display outputs of the FIS tree. By default, the only open FIS output (from fis3) is an output of the FIS tree.

fuzzTree.Outputs

%  Add the output of fis2 outputs to the tree output list.

fuzzTree.Outputs(end+1) = "fis2/output1";

% Display the updated output list of the FIS tree.

fuzzTree.Outputs

% Evaluate the FIS tree. The result contains the outputs from fis3 and fis2.

evalfis(fuzzTree,[0.5 0.2 0.8 0.45])

%% Remove Outputs
% Remove the first output from the list.

fuzzTree.Outputs(1) = [];

% Display the updated output list of the FIS tree.

fuzzTree.Outputs

% Evaluate the FIS tree again. The result now contains the output of only fis2.

evalfis(fuzzTree,[0.5 0.2 0.8 0.45])

% Copyright 2018 The MathWorks, Inc.