defuzzy.m
来自「模糊神经网络与软件计算的各章代码」· M 代码 · 共 34 行
M
34 行
function out = defuzzy(x, mf, option)
%DEFUZZY Defuzzification of MF.
% DEFUZZY(x, mf, option) returns a representative value of mf
% using different defuzzification strategies:
% option = 1 ---> center of area
% option = 2 ---> bisecter of area
% option = 3 ---> mean of max
% Copyright by Jyh-Shing Roger Jang, 6-2-93.
% (Tested on Matlab version 3.5e, DEC 5000)
x = x(:);
mf = mf(:);
data_n = length(x);
if option == 1,
out = sum(mf.*x)/sum(mf);
elseif option == 2,
total_area = sum(mf);
tmp = 0;
for k=1:data_n,
tmp = tmp + mf(k);
if tmp > total_area/2,
break;
end
end
out = (x(k) + x(k-1))/2;
elseif option == 3,
index = find(mf == max(mf));
out = mean(x(index));
else
error('Unknown defuzzification option!');
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?