Azzera filtri
Azzera filtri

Error using FuzzyInfer​enceSystem​/addOutput (line 866) Upper range value for variable must be greater than lower range value. Error in rulepruning (line 24) fis = addOutput(fi

3 visualizzazioni (ultimi 30 giorni)
% 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');
Error using FuzzyInferenceSystem/addOutput (line 866)
Upper range value for variable must be greater than lower range value.
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);

Risposta accettata

Sam Chak
Sam Chak il 24 Mag 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 Commenti
Sam Chak
Sam Chak il 30 Mag 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
Sam Chak il 30 Mag 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
pruneRules not found. Search the documentation for pruneRules docsearch pruneRules
help getRuleValues
getRuleValues not found. Search the documentation for getRuleValues docsearch getRuleValues

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fuzzy Logic Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by