fis = sugfis('Name', "Sugeno_FLC");
fis = addInput(fis, [-ud +ud], 'Name', 'in1');
fis = addMF(fis, 'in1', 'trimf', [-ud -ud ud], 'Name', 'N');
fis = addMF(fis, 'in1', 'trimf', [-ud ud ud], 'Name', 'P');
fis = addInput(fis, [-ud +ud], 'Name', 'in2');
fis = addMF(fis, 'in2', 'trimf', [-ud -ud ud], 'Name', 'N');
fis = addMF(fis, 'in2', 'trimf', [-ud ud ud], 'Name', 'P');
fis = addOutput(fis, [-4.875 4.875], 'Name', 'out');
fis = addMF(fis, 'out', 'constant', -4.875, 'Name', 'NB');
fis = addMF(fis, 'out', 'constant', -1.125, 'Name', 'NS');
fis = addMF(fis, 'out', 'constant', 1.125, 'Name', 'PS');
fis = addMF(fis, 'out', 'constant', 4.875, 'Name', 'PB');
"in1==N & in2==N => out=NB"
"in1==N & in2==P => out=PS"
"in1==P & in2==N => out=NS"
"in1==P & in2==P => out=PB"
fis = addRule(fis, rules);
plotmf(fis, 'input', 1), grid on, xlabel('Error')
title('Error membership functions')
plotmf(fis, 'input', 2), grid on, xlabel('Change in Error')
title('Change in Error membership functions')
sgtitle('Input Fuzzy Sets')
opt = gensurfOptions('NumGridPoints', 51);
xlabel('Error'), ylabel('Change in Error'), zlabel('Fuzzy Control Output')
title ('Fuzzy Control Surface'), axis([-1.5 +1.5 -1.5 +1.5 -5.0 +5.0])
Gp = tf(1, [1 1 1])
Gp =
1
-----------
s^2 + s + 1
Continuous-time transfer function.
[t, x] = ode45(@(t, x) ode(t, x, fis), [0 10], [0; 0]);
plot(t, x(:,1), 'color', [0.8500 0.3250 0.0980]), grid on, hold off
legend('Plant response', 'Closed-loop response', 'location', 'east')
function dx = ode(t, x, fis)
u = - evalfis(fis, x) + sf*r;