Fuzzy controller giving constant output of z = 0.5 (z range [0,1])
9 views (last 30 days)
MATLAB R2017B (18.104.22.1683579) 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
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";
% 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);
% 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')