Documentation Center

  • Trial Software
  • Product Updates

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 a 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

expand all

Add Single Rule to Fuzzy Inference System

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)

Add Multiple Rules to Fuzzy Inference System

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

| |

Was this topic helpful?