Clear Filters
Clear Filters

Fuzzy controller giving constant output of z = 0.5 (z range [0,1])

8 views (last 30 days)
MATLAB R2017B ( 64-bit (win 64)
My fuzzy controller has one input and one output:
The membership functions and rules:
However, in the surface, the output1 starts in 0.5. I think that it should start in 0:
Am I wrong? Any help would be much appreciated.
Thanks in advance

Answers (1)

Sam Chak
Sam Chak on 17 Sep 2022
There is nothing wrong. The reason the Crisp Output starts from is because the linear MF is chosen and the range of the Output MF is from 0 to 1. If the ruleview(fis) command is entered, one can clearly see the result of Aggregation, where the "mom" Defuzzification Method will be applied to obtain the crisp value.
If the Crisp Output value should starts from 0 to 1, then the range of the Output MF should be adjusted from to 1.
fis = mamfis('Name', "Test_FIS");
fis.DefuzzificationMethod = "mom";
fis =
mamfis with properties: Name: "Test_FIS" AndMethod: "min" OrMethod: "max" ImplicationMethod: "min" AggregationMethod: "max" DefuzzificationMethod: "mom" DisableStructuralChecks: 0 Inputs: [0×0 fisvar] Outputs: [0×0 fisvar] Rules: [0×0 fisrule] See 'getTunableSettings' method for parameter optimization.
% Fuzzy Input #1
fis = addInput(fis, [0 1], 'Name', 'FuzIn');
fis = addMF(fis, 'FuzIn', 'linsmf', [0 1], 'Name', 'mfA');
% Fuzzy Output
fis = addOutput(fis, [-1 1], 'Name', 'FuzOut');
fis = addMF(fis, 'FuzOut', 'linsmf', [-1 1], 'Name', 'mfB');
% Plot membership functions
plotmf(fis, 'input', 1), grid on, title('Input')
plotmf(fis, 'output', 1), grid on, title('Output')
% Fuzzy Rules
rules = [...
"FuzIn==mfA => FuzOut=mfB"; ...
fis = addRule(fis, rules);
Warning: ruleview will be removed in a future release. Use the Fuzzy Logic Designer app instead.
% Generate output of Mamdani FIS
opt = gensurfOptions('NumGridPoints', 41);
[x, y, z] = gensurf(fis, opt);
plot(x, z, 'linewidth', 1.5), grid on
xlabel('FuzIn'), ylabel('FuzOut'), title('Crisp Output')


Find more on Fuzzy Inference System Modeling in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!