Evaluate fuzzy inference system
Fuzzy Logic Toolbox
The Fuzzy Logic Controller block implements a fuzzy inference system (FIS) in Simulink®. You specify the FIS to evaluate using the FIS name parameter.
For more information on fuzzy inference, see Fuzzy Inference Process.
To display the fuzzy inference process in the Rule Viewer during simulation, use the Fuzzy Logic Controller with Ruleviewer block.
in
— Input signalFor a single-input fuzzy inference system, the input is a scalar signal. For a multi-input fuzzy system, combine the inputs into a vector signal using blocks such as:
Mux (Simulink)
Vector Concatenate (Simulink)
Bus Creator (Simulink)
out
— Defuzzified output signalFor a single-output FIS, the output is a scalar signal. For a multi-output FIS, the output is a vector signal. To split system outputs into scalar signals, use the Demux (Simulink) block.
fi
— Fuzzified input valuesFuzzified input values, obtained by evaluating the input membership functions of each rule at the current input values.
For a type-1 FIS, fi
is an
NR-by-NU
matrix signal, where NR is the
number of FIS rules. Element (i,j) of
fi
is the value of the input membership function
for the jth input in the ith rule.
For a type-2 FIS, fi
is an
NR-by-(2*NU)
matrix signal. The first NU
columns contain the fuzzified values of the upper membership function
for each rule, and the last NU
columns contain the fuzzified values from the lower membership
functions.
For more information on fuzzifying input values, see Fuzzify Inputs.
To enable this port, select the Fuzzified inputs (fi) parameter.
rfs
— Rule firing strengthsRule firing strengths, obtained by evaluating the antecedent of each rule; that is, applying the fuzzy operator to the values of the fuzzified inputs.
For a type-1 FIS, rfs
is a column vector signal of
length NR, where
NR is the number of
rules, and element i is the firing strength of the
ith rule.
For a type-2 FIS, rfs
is an
NR-by-2 matrix signal.
The first column contains the rule firing strengths generated using
upper membership functions, and the second column contains the rule
firing strengths generated using lower membership functions.
For more information on applying fuzzy operators, see Apply Fuzzy Operator.
To enable this port, select the Rule firing strengths (rfs) parameter.
ro
— Rule outputsRule outputs, obtained by applying the rule firing strengths to the output membership functions using the implication method specified in the FIS.
For a type-1 Mamdani FIS, ro
is an
NS-by-(NRNY)
matrix signal, where NR is the
number of rules, NY is the
number of outputs, and NS is
the number of sample points used for evaluating output variable ranges.
Each column of ro
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 type-2 Mamdani FIS, ro
is an
NS-by-(2*NR*NY)
matrix signal. The first
NR*NY
columns contain the rule outputs generated using upper membership
functions, and the last
NR*NY
columns contain the rule outputs generated using lower membership
functions.
For a type-1 Sugeno system, each rule output is a scalar value. In
this case, ro
is an
NR-by-NY
matrix signal. Element (j,k) of
ro
is the value of the kth
output variable for the jth rule.
For a type-2 Sugeno system, ro
is an
NR-by-(3*NY)
array. The first NY columns
contain the rule output levels. The next
NY columns contain the
corresponding rule firing strengths generated using upper membership
functions. The last NY columns
contain the rule firing strengths generated using lower membership
functions. For example, in a three-output system, columns 4 and 7
contain the firing strengths for the output levels in column 1.
For more information on fuzzy implication, see Apply Implication Method.
To enable this port, select the Rule outputs (ro) parameter.
To specify NS, use the Number of samples for output discretization parameter.
ao
— Aggregated outputAggregate output for each output variable, obtained by combining the corresponding outputs from all the rules using the aggregation method specified in the FIS.
For a type-1 Mamdani fuzzy inference system, the aggregate result for
each output variable is a fuzzy set. In this case, ao
is as an
NS-by-NY
matrix signal, where NY is the
number of outputs and NS is
the number of sample points used for evaluating output variable ranges.
Each column of ao
contains the aggregate fuzzy set
for one output variable.
For a type-2 Mamdani FIS, the aggregate result for each output
variable is a fuzzy set. In this case, ao
is as an
NS-by-(2*NY)
matrix signal. The first NY
columns contain the aggregated outputs generated using upper membership
functions, and the last NY
columns contain the aggregated outputs generated using lower membership
functions.
For a type-1 Sugeno system, the aggregate result for each output
variable is a scalar value. In this case, ao
is a row
vector of length NY, where
element k is the sum of the rule outputs for the
kth output variable.
For a type-2 Sugeno system, ao
is an
NR-by-(3*NY)
array. aggregatedOut
contains the same data as
ro
with the columns sorted based on the output
levels. For example, in a three-output system, when the output levels in
column 1 are sorted, the corresponding firing strengths in columns 4 and
7 are adjusted accordingly.
For more information on fuzzy aggregation, see Aggregate All Outputs.
To enable this port, select the Aggregated outputs (ao) parameter.
To specify NS, use the Number of samples for output discretization parameter.
FIS name
— Fuzzy inference systemmamfis
object | sugfis
object | mamfistype2
object | sugfistype2
object | file nameFuzzy inference system to evaluate, specified as one of the following:
mamfis
or sugfis
object — Specify the name of a type-1 FIS
object in the MATLAB® workspace.
mamfistype2
or sugfistype2
object — Specify the name of a
type-2 FIS object in the MATLAB workspace.
File name — Specify the name of a .fis
file
in the current working folder or on the MATLAB path. Including the file extension in the file
name is optional.
To save a type-1 fuzzy inference system to a
.fis
file:
In Fuzzy Logic Designer or Neuro-Fuzzy Designer, select File > Export > To File.
At the command line, use writeFIS
.
To save a type-2 fuzzy inference system to a
.fis
file, use
wrtieFIS
.
Block Parameter:
FIS |
Type: string, character vector |
Default:
"'tipper.fis'" |
Number of samples for output discretization
— Number of points in output fuzzy sets1
Number of samples for discretizing the range of output variables,
specified as an integer greater than 1
. This value
corresponds to the number of points in the output fuzzy set for each
rule.
To reduce memory usage while evaluating a Mamdani FIS, specify a lower number of samples. Doing so sacrifices the accuracy of the defuzzified output value. Specifying a low number of samples can make the output area for defuzzification zero. In this case, the defuzzified output value is the midpoint of the output variable range.
Note
The block ignores this parameter when evaluating a Sugeno FIS.
Block Parameter:
OutputSampleNumber |
Type: string, character vector |
Default:
"101" |
Data type
— Signal data typedouble
(default) | single
| fixed-point
| expression
Signal data type, specified as one of the following:
double
— Double-precision
signals
single
— Single-precision
signals
fixdt(1,16,0)
— Fixed-point signals
with binary point scaling
fixdt(1,16,2^0,0)
— Fixed-point
signals with slope and bias scaling
Expression — Expression that evaluates to one of these data types
For fixed-point data types, you can configure the signedness, word length, and scaling parameters using the Data Type Assistant. For more information, see Specifying a Fixed-Point Data Type (Simulink).
Block Parameter:
DataType |
Type: string, character vector |
Values:
"double" , "single" ,
"fixdt(1,16,0)" ,
"fixdt(1,16,2^0,0)" |
Default:
"double" |
Fuzzified inputs (fi)
— Enable fi
output portoff
(default) | on
Enable output port for accessing intermediate fuzzified input data.
Block Parameter:
FuzzifiedInputs |
Type: string, character vector |
Values:
"off" , "on" |
Default:
"off" |
Rule firing strengths (rfs)
— Enable rfs
output portoff
(default) | on
Enable output port for accessing intermediate rule firing strength data.
Block Parameter:
RuleFiringStrengths |
Type: string, character vector |
Values:
"off" , "on" |
Default:
"off" |
Rule outputs (ro)
— Enable ro
output portoff
(default) | on
Enable output port for accessing intermediate rule output data.
Block Parameter:
RuleOutputs |
Type: string, character vector |
Values:
"off" , "on" |
Default:
"off" |
Aggregated outputs (ao)
— Enable ao
output portoff
(default) | on
Enable output port for accessing intermediate aggregate output data.
Block Parameter:
AggregatedOutputs |
Type: string, character vector |
Values:
"off" , "on" |
Default:
"off" |
Simulate using
— Simulation modeInterpreted
execution
(default) | Code generation
Simulation mode, specified as one of the following:
Interpreted execution
— Simulate
fuzzy systems using precompiled MEX files for
single
and
double
data types. Using this
option reduces the initial compilation time of the model.
Code generation
— Simulate fuzzy
system without precompiled MEX files. Use this option when
simulating fuzzy systems for code generation
applications.
For fixed-point data types, the Fuzzy Logic Controller
block always simulates using Code generation
mode.
Block Parameter:
SimulateUsing |
Type: string, character vector |
Values:
"Interpreted execution" , "Code
generation" |
Default:
"Interpreted execution" |
Out of range input value
— Diagnostic message behavior when an input is out of rangewarning
(default) | error
| none
Diagnostic message behavior when an input is out of range, specified as one of the following:
warning
— Report the diagnostic
message as a warning.
error
— Report the diagnostic
message as an error.
none
— Do not report the diagnostic
message.
When an input value is out of range, corresponding rules in the fuzzy system can have unexpected firing strengths.
Diagnostic messages are provided only when the
Simulate using parameter is
Interpreted execution
.
Block Parameter:
OutOfRangeInputValueMessage |
Type: string, character vector |
Values:
"warning" , "error" ,
"none" |
Default:
"warning" |
No rule fired
— Diagnostic message behavior when no rules firewarning
(default) | error
| none
Diagnostic message behavior when no rules fire for a given output variable, specified as one of the following:
warning
— Report the diagnostic
message as a warning.
error
— Report the diagnostic
message as an error.
none
— Do not report the diagnostic
message.
When No rule fired is
warning
or
none
and no rules fire for a given
output, the defuzzified output value is set to its mean range
value.
Diagnostic messages are provided only when the
Simulate using parameter is
Interpreted execution
.
Block Parameter:
NoRuleFiredMessage |
Type: string, character vector |
Values:
"warning" , "error" ,
"none" |
Default:
"warning" |
Empty output fuzzy set
— Diagnostic message behavior when an output fuzzy set is emptywarning
(default) | error
| none
Diagnostic message behavior when an output fuzzy set is empty, specified as one of the following:
warning
— Report the diagnostic
message as a warning.
error
— Report the diagnostic
message as an error.
none
— Do not report the diagnostic
message.
When Empty output fuzzy set is
warning
or
none
and an output fuzzy set is empty,
the defuzzified value for the corresponding output is set to its mean
range value.
This diagnostic message applies to Mamdani systems only.
Diagnostic messages are provided only when the
Simulate using parameter is
Interpreted execution
.
Block Parameter:
EmptyOutputFuzzySetMessage |
Type: string, character vector |
Values:
"warning" , "error" ,
"none" |
Default:
"warning" |
Warns starting in R2019b
Support for representing fuzzy inference systems as structures will be removed in a future
release. Use mamfis
and
sugfis
objects
instead. There are differences between these representations that require updates to your
code. These differences include:
Object property names that differ from the corresponding structure fields.
Objects store text data as strings rather than as character vectors.
Also, all Fuzzy Logic Toolbox™ functions that accepted or returned fuzzy inference systems as structures now
accept and return either mamfis
or sugfis
objects.
To convert existing fuzzy inference system structures to objects, use the convertfis
function.
evalfis
| genfis
| mamfis
| mamfistype2
| readfis
| sugfis
| sugfistype2
| writeFIS