clear
clc
%对象模型
Ts = 0.1;
Plant = c2d(zpk([],[-1 -3 -5],1),Ts);
%PID参数优化
C0 = pid(1,1,1,'Ts',Ts,'IF','B','DF','B');
C = pidtune(Plant,C0)
[Kp, Ki, Kd] = piddata(C);
%比例因子确定
GE = 10;
GCE = GE*(Kp-sqrt(Kp^2-4*Ki*Kd))/2/Ki;
GCU = Ki/GE;
GU = Kd/GCE;
%连续模糊PID控制建立
FIS = newfis('FIS','sugeno');
%%
% 定义输入E:
FIS = addvar(FIS,'input','E',[-10 10]);
FIS = addmf(FIS,'input',1,'Negative','gaussmf',[7 -10]);
FIS = addmf(FIS,'input',1,'Positive','gaussmf',[7 10]);
%%
% 定义输入CE:
FIS = addvar(FIS,'input','CE',[-10 10]);
FIS = addmf(FIS,'input',2,'Negative','gaussmf',[7 -10]);
FIS = addmf(FIS,'input',2,'Positive','gaussmf',[7 10]);
%%
% 定义输出u:
FIS = addvar(FIS,'output','u',[-20 20]);
FIS = addmf(FIS,'output',1,'Min','constant',-20);
FIS = addmf(FIS,'output',1,'Zero','constant',0);
FIS = addmf(FIS,'output',1,'Max','constant',20);
% 定义规则:
%
% # If |E| is Negative and |CE| is Negative then |u| is -20
% # If |E| is Negative and |CE| is Positive then |u| is 0
% # If |E| is Positive and |CE| is Negative then |u| is 0
% # If |E| is Positive and |CE| is Positive then |u| is 20
ruleList = [1 1 1 1 1;... % Rule 1
1 2 2 1 1;... % Rule 2
2 1 2 1 1;... % Rule 3
2 2 3 1 1]; % Rule 4
FIS = addrule(FIS,ruleList);
gensurf(FIS) %生成模糊控制器
评论0