to get output from fuzzy logic toolbox

11 次查看(过去 30 天)
i want the output as probability value but i am only getting a graph. i want to know how can we obtain values from surface viewer of fuzzy logic toolbox of Matlab software?

回答(1 个)

Sam Chak
Sam Chak 2022-9-16
The graph or output values from the surface viewer on the Fuzzy Logic App are actually defuzzified output values.
To view the defuzzified output values for specific input values or vector, use evalfis() function.
fis = mamfis('Name', "Test_FIS");
% Fuzzy Input #1
fis = addInput(fis, [-1 1], 'Name', 'E');
fis = addMF(fis, 'E', 'zmf', [-0.5 0.25], 'Name', 'N');
fis = addMF(fis, 'E', 'gaussmf', [0.25 0], 'Name', 'Z');
fis = addMF(fis, 'E', 'smf', [-0.25 0.5], 'Name', 'P');
% Fuzzy Output
fis = addOutput(fis, [-1 1], 'Name', 'U');
fis = addMF(fis, 'U', 'zmf', [-0.5 0.25], 'Name', 'N');
fis = addMF(fis, 'U', 'gaussmf', [0.25 0], 'Name', 'Z');
fis = addMF(fis, 'U', 'smf', [-0.25 0.5], 'Name', 'P');
% Plot Membership functions
figure(1)
subplot(2,1,1)
plotmf(fis, 'input', 1), grid on, title('Input')
subplot(2,1,2)
plotmf(fis, 'output', 1), grid on, title('Output')
% Fuzzy Rules
rules = [...
"E==N => U=N"; ...
"E==Z => U=Z"; ...
"E==P => U=P"; ...
];
fis = addRule(fis, rules);
% Generate output of Mamdani FIS
figure(2)
opt = gensurfOptions('NumGridPoints', 201);
gensurf(fis, opt), grid on
hold on
input_E = [0.5 -0.5];
output_U = evalfis(fis, input_E)
output_U = 2×1
0.4904 -0.4904
q = plot(input_E, output_U, 'o', 'MarkerSize', 10);
q.LineWidth = 1.5;

类别

Help CenterFile Exchange 中查找有关 Fuzzy Inference System Modeling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by