📄 fuz_mod.m
字号:
function out=fuz_mod(inputs,centers,bases,par,bias)%FUZ_MOD%% out=fuz_mod(inputs,centers,bases,par,bias)%% out[no_data,1] %% inputs[no_data,no_var]% centers[no_rules,no_var] centers of the membership functions% bases[no_rules,no_var] bases of the membership functions% par[no_rules,no_par] parameters of the consequent of each rule% bias[1,1]% % Given an input matrix and the matrices centers, bases, par and bias, % fuz_mod returns the corresponding output of the fuzzy system% % The following global variable are required: % memb_fun: 'gaussian'/'triangular' % arch: 'weigthed'/'comb' % format_out: 'linear'/'constant' %_______________________________________________________6 April 1996____global memb_fun;global arch;global format_out;[no_data,no_var]=size(inputs);[no_rules,no_var]=size(centers);[no_rules_,no_par]=size(par); if strcmp(format_out,'linear') y=[inputs,ones(no_data,1)]*par';endif strcmp(format_out,'constant') y=ones(no_data,1)*par';endSum_w=zeros(no_data,1);Sum_wy=zeros(no_data,1);for i=1:no_rules w=ones(no_data,1); %initialization of the degree of match %of the inputs to the premise of the i-th rule for j=1:no_var %match[no_data,1] is the degree of match of each %datum to the premise of the i-th rule for what %concerns the j-th direction of the input space if strcmp(memb_fun,'gaussian') match=exp(-((inputs(:,j)-centers(i,j)).^2)/bases(i,j)); end if strcmp(memb_fun,'triangular') match=max(0, ones(no_data,1)-2*abs(inputs(:,j)-centers(i,j))/bases(i,j)); end w=w.*match; end Sum_wy=Sum_wy + w.*y(:,i); Sum_w=Sum_w + w; endSum_w=Sum_w + (Sum_w==0); %if Sum_w=0 then Sun_w=1 % n.b. in this case Sum_wy=0if strcmp(arch, 'weigthed') out=Sum_wy./Sum_w;endif strcmp(arch, 'comb') out=Sum_wy;endout=out+bias*ones(size(out));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -