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
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michael Bamidele
el 24 de Mayo de 2024
Comentada: Sam Chak
el 30 de Mayo de 2024
% 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 comentarios
Respuesta aceptada
Sam Chak
el 24 de Mayo de 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 comentarios
Sam Chak
el 30 de Mayo de 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
el 30 de Mayo de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!