evalfis

Evaluate fuzzy inference system

Syntax

output = evalfis(fis,input)
output = evalfis(fis,input,options)
[output,fuzzifiedIn,ruleOut,aggregatedOut,ruleFiring] = evalfis(___)

Description

example

output = evalfis(fis,input) evaluates the fuzzy inference system fis for the input values in input and returns the resulting output values in output.

example

output = evalfis(fis,input,options) evaluates the fuzzy inference system using specified evaluation options.

example

[output,fuzzifiedIn,ruleOut,aggregatedOut,ruleFiring] = evalfis(___) returns intermediate results from the fuzzy inference process. This syntax is not supported when fis is a fistree object.

Examples

collapse all

Load FIS.

fis = readfis('tipper');

Evaluate the FIS when the first input is 2 and the second input is 1.

output = evalfis(fis,[2 1])
output = 7.0169

Load FIS.

fis = readfis('tipper');

Specify the input combinations to evaluate using an array with one row per input combination.

input = [2 1;
         4 5;
         7 8];

Evaluate the FIS for the specified input combinations.

output = evalfis(fis,input)
output = 3×1

    7.0169
   14.4585
   20.3414

Each row of output is the defuzzified output value for the corresponding row of input.

Load FIS.

fis = readfis('tipper');

Create an evalfisOptions option set, specifying the number of samples in the output fuzzy sets.

options = evalfisOptions('NumSamplePoints',50);

Evaluate the FIS using this option set.

output = evalfis(fis,[2 1],options);

Create a pair of Mamdani fuzzy inference systems.

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

Define the connection between the two.

con = ["fis1/output1" "fis2/input1"];

Create a tree of fuzzy inference systems.

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

Create an evalfisOptions option set, specifying the number of samples in the output fuzzy sets.

options = evalfisOptions('NumSamplePoints',50);

Evaluate the fistree object using a specified input combination and this option set.

y = evalfis(tree,[0.5 0.2 0.7],options)
y = 0.1553

Load FIS.

fis = readfis('tipper');

Evaluate the FIS, and return the intermediate inference results.

[output,fuzzifiedIn,ruleOut,aggregatedOut,ruleFiring] = evalfis(fis,[2 1]);

You can examine the intermediate results to understand or visualize the fuzzy inference process. For example, view the aggregated output fuzzy set, which is the fuzzy set that evalfis defuzzifies to find the output value. Also, plot the defuzzified output value.

outputRange = linspace(fis.output.range(1),fis.output.range(2),length(aggregatedOut))'; 
plot(outputRange,aggregatedOut,[output output],[0 1])
xlabel('Tip')
ylabel('Output Membership')
legend('Aggregated output fuzzy set','Defuzzified output')

The length of aggregatedOutput corresponds to the number of sample points used to discretize output fuzzy sets.

Input Arguments

collapse all

Fuzzy inference system to be evaluated, specified as a mamfis object, sugfis object, or fistree object.

To create a fuzzy inference system, you can:

Use fistree to create a tree of interconnected fuzzy inference systems to evaluate. Multiple output arguments are not supported when using a fistree object.

For code generation applications, you can also specify fis as a homogeneous structure create using getFISCodeGenerationData. For an example, see Generate Code for Fuzzy System Using MATLAB Coder.

Input values, specified as an M-by-NU array, where NU is the number of input variables in fis and M is the number of input combinations to evaluate.

evalfis supports double-precision or single-precision input values.

Evaluation options, specified as an evalfisOptions object.

Output Arguments

collapse all

Output values, returned as an M-by-NY array, where NY is the number of output variables in fis. evalfis evaluates fis for each row of input and returns the resulting defuzzified outputs in the corresponding row of output.

Fuzzified input values, returned as an NR-by-NU array, where NR is the number of rules in fis. Element (i,j) of fuzzifiedIn is the value of the input membership function for the jth input in the ith rule.

If input specifies multiple input combinations, then fuzzifiedIn corresponds to the combination in the last row of input.

For more information on fuzzifying input values, see Fuzzify Inputs.

Rule outputs, returned as an NS-by-(NRNY) array or an NR-by-NY array, where NS is the number of sample points used for evaluating output variable ranges. To obtain the output for each rule, evalfis applies the firing strength from the rule antecedent to the output membership function using the implication method specified in fis.

For a Mamdani system, each rule output is a fuzzy set. In this case, ruleOut is an NS-by-(NRNY) array. Each column of ruleOut contains the output fuzzy set for one rule. The first NR columns contain the rule outputs for the first output variable, the next NR columns correspond to the second output variable, and so on.

For a Sugeno system, each rule output is a scalar value. In this case, ruleOut is an NR-by-NY array. Element (j,k) of ruleOut is the value of the kth output variable for the jth rule.

If input specifies multiple input combinations, then ruleOut corresponds to the combination in the last row of input.

For more information on fuzzy implication, see Apply Implication Method and What Is Sugeno-Type Fuzzy Inference?

Aggregated output for each output variable, returned as an NS-by-NY array or a row vector of length NY. For each output variable, evalfis combines the corresponding outputs from all the rules using the aggregation method specified in fis.

For a Mamdani system, the aggregate result for each output variable is a fuzzy set. In this case, aggregatedOut is as an NS-by-NY array. Each column of aggregatedOut contains the aggregate fuzzy set for one output variable.

For a Sugeno system, the aggregate result for each output variable is a scalar value. In this case, aggregatedOut is a row vector of length NY, where element k is the aggregate result for the kth output variable.

If input specifies multiple input combinations, then aggregatedOut corresponds to the combination in the last row of input.

For more information on fuzzy aggregation, see Aggregate All Outputs and What Is Sugeno-Type Fuzzy Inference?

Rule firing strength, returned as a column vector of length NR. To obtain the firing strength for each rule, evalfis evaluates the rule antecedents; that is, it applies fuzzy operator to the values of the fuzzified inputs.

If input specifies multiple input combinations, then ruleFiring corresponds to the combination in the last row of input.

For more information on applying the fuzzy operator, see Apply Fuzzy Operator.

Alternative Functionality

App

You can evaluate fuzzy inference systems using the Rule Viewer in the Fuzzy Logic Designer app.

Simulink Block

You can evaluate fuzzy inference systems using the Fuzzy Logic Controller block. For more information on mapping the arguments of evalfis to the Fuzzy Logic Controller block, see Simulate Fuzzy Inference Systems in Simulink.

Compatibility Considerations

expand all

Behavior changed in R2018b

Behavior changed in R2018a

Behavior changed in R2018a

Behavior changed in R2018a

Extended Capabilities

Introduced before R2006a