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

fis2 = parsrule(fis,txtRuleList)
fis2 = parsrule(fis,txtRuleList,ruleFormat)
fis2 = parsrule(fis,txtRuleList,ruleFormat,lang) 

Description

This function parses the text that defines the rules (txtRuleList) for a MATLAB® workspace FIS variable, fis, and returns an FIS structure with the appropriate rule list in place. If the original input FIS structure, fis, has any rules initially, they are replaced in the new structure, fis2.

Three different rule formats (indicated by ruleFormat) are supported: 'verbose', 'symbolic', and 'indexed'. The default format is 'verbose'. When the optional language argument, lang, is used, the rules are parsed in verbose mode, assuming the key words are in the language, lang. This language must be either 'english', 'francais', or 'deutsch'. The key language words in English are if, then, is, AND, OR, and NOT.

Examples

collapse all

Load a fuzzy inference system (FIS).

a = readfis('tipper');

Add a rule to the FIS.

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

Verify the rules associated with the FIS.

showrule(a2)
ans =

1. If (service is poor) then (tip is generous) (1)

Load a fuzzy inference system (FIS).

a = readfis('tipper');

Add multiple rules to the FIS.

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';
rules = char(rule1,rule2,rule3);

a2 = parsrule(a,rules);

Verify the rules associated with the FIS.

showrule(a2)
ans =

1. If (service is poor) or (food is rancid) then (tip is cheap) (1)           
2. If (service is good) then (tip is average) (1)                             
3. If (service is excellent) or (food is delicious) then (tip is generous) (1)

See Also

| |

Introduced before R2006a

Was this topic helpful?