parsrule
(Removed) Parse fuzzy rules
parsrule has been removed. Use addRule instead.
For more information, see Version History.
Description
parses the rules in outFIS = parsrule(inFIS,ruleList,Name,Value)ruleList using options specified by one or more
Name,Value pair arguments.
Examples
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
serviceispoororfoodisrancidthentipischeap.If
serviceisexcellentandfoodis notrancidthentipisgenerous.
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
angleissmallandvelocityisbig, thenforceisnegBigandforce2isposBig2.If
angleis notsmallandvelocityissmall, thenforceisposSmallandforce2isnegSmall2.
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
Input fuzzy inference system, specified as a 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 Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: 'Format','symbolic' sets the rule format to symbolic
expressions.
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
1is used.You can specify the rule language using the
Languageoption.'symbolic'— Use language-neutral symbolic expressions.'service==poor | food==rancid => tip=cheap 1'
Specify symbolic expressions using the following symbols.
Rule Component Symbol 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
1is 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 Component | English | French | German |
|---|---|---|---|
| Start of antecedent | if | si | wenn |
| AND | and | et | und |
| OR | or | ou | oder |
| Start of consequent (implication) | then | alors | dann |
| IS | is | est | ist |
| IS NOT | is not | n''est_pas | ist nicht |
Output Arguments
Version History
Introduced before R2006aparsrule has been removed. Use addRule instead.
If you previously added rules using linguistic or symbolic expressions with
parsrule, you can specify rules using the same expressions with
addrule. addRule automatically detects the
format of the strings or character vectors in your rule list. Therefore, it is no longer
necessary to specify the rule format. To add a rule list using addRule,
use the following command:
fis = addRule(fis,rules);
Previously, you could add rules using indexed expressions with
parsrule.
rule1 = "1 2, 1 4 (1) : 1"; rule2 = "-1 1, 3 2 (1) : 1"; rules = [rule1 rule2]; fis = parsrule(fis,rules,'Format','indexed');
Now, specify these rules using arrays of indices.
rule1 = [1 2 1 4 1 1]; rule2 = [-1 1 3 2 1 1]; rules = [rule1; rule2]; fis = addRule(fis,rules);
If you previously specified rules using the 'Language' name-value
argument with parsrule, this functionality has been removed and there
is no replacement. Specify your rules using addRule with a different
rule format.
Previously, parsrule replaced the entire rule list in your fuzzy
system. addRule appends your specified rules to the rule list.
parsrule issues a warning that it will be removed in a future
release.
parsrule runs without warning, but Code Analyzer indicates that
parsrule will be removed in a future release.
To specify options for creating new fuzzy inference systems, you now use name-value pair arguments. Any name-value pair arguments that you do not specify remain at their default values.
Previously, you specified options using optional input arguments
ruleFormat and lang.
outFIS = parsrule(inFIS,ruleList,ruleFormat,lang);
Starting in R2017a, modify your code to use one or more name-value pair arguments. For
example, add a list of rules in 'symbolic' format.
fis = parsrule(inFIS,ruleList,'Format','symbolic');
The following table shows the mapping of the old input arguments to the new name-value pair arguments.
| Old Input Argument | New Name-Value Argument |
|---|---|
ruleFormat | 'Format' |
lang | 'Language' |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)