Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

parsrule

Parse fuzzy rules

Syntax

outFIS = parsrule(inFIS,ruleList)
outFIS = parsrule(inFIS,ruleList,Name,Value)

Description

example

outFIS = parsrule(inFIS,ruleList) returns a fuzzy inference system, outFIS, that is equivalent to the input fuzzy system, inFIS. but with fuzzy rules replaced by the rules specified in ruleList.

example

outFIS = parsrule(inFIS,ruleList,Name,Value) parses the rules in ruleList using options specified by one or more Name,Value pair arguments.

Examples

collapse all

Load a fuzzy inference system (FIS).

fis = readfis('tipper');

Specify if-then rules using the default 'verbose' format.

rule1 = "If service is poor or food is rancid then tip is cheap";
rule2 = "If service is excellent and food is not rancid then tip is generous";
rules = [rule1 rule2];

Add the rules to the FIS.

fis2 = parsrule(fis,rules);

fis2 is equivalent to fis, except that the rule base is replaced with the specified rules.

Load a fuzzy inference system (FIS).

fis = readfis('tipper');

Specify the following rules using symbols:

  • If service is poor or food is rancid then tip is cheap.

  • If service is excellent and food is not rancid then tip is generous.

rule1 = "service==poor | food==rancid => tip=cheap";
rule2 = "service==excellent & food~=rancid => tip=generous";
rules = [rule1 rule2];

Add the rules to the FIS using the 'symbolic' format.

fis2 = parsrule(fis,rules,'Format','symbolic');

Load fuzzy inference system (FIS).

fis = readfis('mam22.fis');

Specify the following rules using membership function indices:

  • If angle is small and velocity is big, then force is negBig and force2 is posBig2.

  • If angle is not small and velocity is small, then force is posSmall and force2 is negSmall2.

rule1 = "1 2, 1 4 (1) : 1";
rule2 = "-1 1, 3 2 (1) : 1";
rules = [rule1 rule2];

Add rules to FIS using the 'indexed' format.

fis2 = parsrule(fis,rules,'Format','indexed');

Load a fuzzy inference system (FIS).

fis = readfis('tipper');

Specify if-then rules using French keywords.

rule1 = "Si service est poor ou food est rancid alors tip est cheap";
rule2 = "Si service est excellent et food n''est_pas rancid alors tip est generous";
rules = [rule1 rule2];

Add the rules to the FIS.

fis2 = parsrule(fis,rules,'Language','francais');

Load a fuzzy inference system (FIS).

a = readfis('tipper');

Add a rule to the FIS.

ruleTxt = 'If service is poor then tip is cheap';
a2 = parsrule(a,ruleTxt,'verbose');

Input Arguments

collapse all

Input fuzzy inference system, specified as an FIS structure. parsrule does not modify inFIS.

Fuzzy rules, specified as one of the following:

  • Character array where each row corresponds to a rule. For example:

    rule1 = 'If service is poor or food is rancid then tip is cheap';
    rule2 = 'If service is good then tip is average';
    rule3 = 'If service is excellent or food is delicious then tip is generous';
    ruleList = char(rule1,rule2,rule3);
  • String array, where each element corresponds to a rule. For example:

    ruleList = ["If service is poor or food is rancid then tip is cheap";
                "If service is good then tip is average";
                "If service is excellent or food is delicious then tip is generous"];
  • Character vector or string to specify a single rule.

You can change the rule format and language using the Format and Language options.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Format','symbolic' sets the rule format to symbolic expressions.

collapse all

Rule format, specified as the comma-separated pair consisting 'Format' and one of the following:

  • 'verbose' — Use linguistic expressions.

    'If service is poor or food is rancid then tip is cheap 1'

    Specify the rule weight at the end of the rule text. If you omit the weight, a default value of 1 is used.

    You can specify the rule language using the Language option.

  • 'symbolic' — Use language-neutral symbolic expressions.

    'service==poor | food==rancid => tip=cheap 1'

    Specify symbolic expressions using the following symbols.

    Rule ComponentSymbol
    AND&
    OR|
    IS (in antecedent)==
    IS (in consequent)=
    IS NOT~=
    Implication (then)=>

    Specify the rule weight at the end of the rule text. If you omit the weight, a default value of 1 is used.

  • 'indexed' — Use input and output membership function (MF) indices.

    Specify indexed rules in the following format:

    '<input MFs>, <output MFs>, (<weight>) : <logical operator - 1(AND), 2(OR)>'

    For example:

    '1 1, 1 (1) : 2'

    To indicate NOT operations for input and output membership functions, use negative indices. For example, to specify “not the second membership function,” use -2.

    To indicate a don’t care condition for an input or output membership function, use 0.

Rule language for 'verbose' format, specified as one of the following:

  • 'english' — Specify rules in English.

    'If service is poor or food is rancid then tip is cheap'
  • 'francais' — Specify rules in French.

    'Si service est poor ou food est rancid alors tip est cheap'
  • 'deutsch' — Specify rules in German.

    'Wenn service ist poor oder food ist rancid dann tip ist cheap'

The software parses the rules in ruleList using the following keywords.

Rule ComponentEnglishFrenchGerman
Start of antecedentifsiwenn
ANDandetund
ORorouoder
Start of consequent (implication)thenalorsdann
ISisestist
IS NOTis notn''est_pasist nicht

Output Arguments

collapse all

Fuzzy inference system, returned as an FIS structure. outFIS is the same as inFIS, except that the rule list contains only the rules specified in ruleList.

Introduced before R2006a

Was this topic helpful?