📄 genb_fis.m
字号:
function PI=genb_fis(x)
% Build a system from scratch
% gena_fis.m
% THIS PROGRAM SHOWS YOU TO GENERATE A FIS PROGRAM FROM NOTHING.
global Kp Ki Kd wn zeta pidfuzz Emin main_loop tippa MIN_offset
Kp=round4dp(x(1));
Ki=round4dp(x(2));
Kd=round4dp(x(3));
if main_loop==1
if exist('gena_data.mat')
load gena_data
end
end
%Kp=97.29;Ki=1.17;Kd=30.1863;
%Kp=176.43; Ki= 2.67; Kd= 42.97;
% Given tippa
a=tippa;
a=rmmf(a,'output',1,'tight','mf',2);
a=addmf(a,'output',1,'tight','linear',[0 Kp Ki Kd 0]);
% APPEND RULES to tipp
rule_List=[...
1 1 1 1 1 1 1
2 1 1 1 2 1 1
];
a=addrule(a,rule_List);
writefis(a,'tippa'); % SAVE to tipp.fis
tippa=readfis('pidfuzz'); % READ it BACK for fuzzy GUI use.
%IN=[1 1 1 1] % evaluate FIS
%evalfis(IN,tippa)
[t,x,Y]=sim('pidb_fuzzy',[0 10]); ERR=Y(:,1);
N=length(ERR); ERR=ERR(N);
PI=MIN_offset-ERR;
if Emin>=ERR
Emin=ERR; save gena_data Kp Ki Kd Emin
fprintf('\nKp=%5.2f; Ki=%6.2f; Kd=%6.2f; Emin=%10.4f;\n',Kp,Ki,Kd,Emin);
else
fprintf('>');
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -