Error using FuzzyInferenceSystem/addOutput (line 866) Upper range value for variable must be greater than lower range value. Error in rulepruning (line 24) fis = addOutput(fi
Afficher commentaires plus anciens
% Create a sample FIS
% fis = mamfis('tipper');
% fis = mamfis("NumInputs",3,"NumOutputs",1)
fis = mamfis('Name',"tipper");
fis = addInput(fis,'NumMFs',3,'MFType',"gaussmf");
fis.Inputs(1).Name = "service";
fis.Inputs(1).Range = [0 10];
% fis = addInput(fis, 'service', [0 10]);
% fis = addInput(fis, 'food', [0 10]);
% fis = addOutput(fis, 'tip', [0 30]);
fis.Inputs(2).Name = "food";
fis.Inputs(2).Range = [0 10];
fis.Outputs(1).Name = "tip";
fis.Outputs(1).Range = [0 30];
% Add output membership functions
% Add output membership functions
out_mf1 = zmf(fis.Outputs(1).Range, [0 15]); % 'low'
fis = addOutput(fis, out_mf1, 'Name', 'low');
out_mf2 = zmf(fis.Outputs(1).Range, [10 20]); % 'medium'
fis = addOutput(fis, out_mf2, 'Name', 'medium');
out_mf3 = zmf(fis.Outputs(1).Range, [15 25]); % 'high'
fis = addOutput(fis, out_mf3, 'Name', 'high');
out_mf4 = zmf(fis.Outputs(1).Range, [20 30]); % 'very_high'
fis = addOutput(fis, out_mf4, 'Name', 'very_high');
% Add rules
rules = [...
"If service is poor and food is rancid, then tip is cheap"; ...
"If service is good and food is delicious, then tip is generous"; ...
"If service is excellent and food is amazing, then tip is very generous"; ...
"If service is poor and food is delicious, then tip is average"; ...
"If service is good and food is rancid, then tip is little"; ...
];
fis = addRule(fis, rules);
% Perform rule pruning
[pruned_fis, pruned_rules, pruned_outputs] = pruneRules(fis, 0.2);
% Get remaining rules
remaining_rules = getRuleValues(pruned_fis);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Fuzzy Logic Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
