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
3 vues (au cours des 30 derniers jours)
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);
0 commentaires
Réponse acceptée
Sam Chak
le 24 Mai 2024
The syntax to add output membership functions is incorrect. Use 'addMF()' instead. However, it is highly recommended to use the Fuzzy Logic Designer app with interactive user interface.
% Create a sample FIS
fis = mamfis('Name',"tipper");
fis = addInput(fis,'NumMFs',3,'MFType',"gaussmf");
% Create Fuzzy Input #1
fis.Inputs(1).Name = "service";
fis.Inputs(1).Range = [0 10];
% Create Fuzzy Input #2
fis.Inputs(2).Name = "food";
fis.Inputs(2).Range = [0 10];
% Create Fuzzy Output #1
fis.Outputs(1).Name = "tip";
fis.Outputs(1).Range = [0 30];
% Add output membership functions
fis = addMF(fis, 'tip', 'zmf', [ 0 15], 'Name', 'low');
fis = addMF(fis, 'tip', 'zmf', [10 20], 'Name', 'medium');
fis = addMF(fis, 'tip', 'zmf', [15 25], 'Name', 'high');
fis = addMF(fis, 'tip', 'zmf', [20 30], 'Name', 'very_high');
plotmf(fis, 'output', 1), grid on, title('Tip')
% % 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);
8 commentaires
Sam Chak
le 30 Mai 2024
You're welcome, @Michael Bamidele. Are you designing a decision-making system based on the concept of pure human reasoning (no math involved) using Fuzzy Logic just like the Tipper example?
Sam Chak
le 30 Mai 2024
I neglected to mention that both the pruneRules() and getRuleValues() functions are not built-in MATLAB functions. As a result, I am unable to test them. Are these functions available from the MATLAB File Exchange?
help pruneRules
help getRuleValues
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fuzzy Logic Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!