马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
是一个三输入两输出的模糊控制,运行报错。
%定义输入和输出变量及隶属度函数
a=newfis('wenkongqi');
a=addvar(a,'input','e1',[-6 6]);
a=addmf(a,'input',1,'NB','trimf',[-6,-4.5,-3]);
a=addmf(a,'input',1,'NM','trimf',[-4.5,-3,-1.5]);
a=addmf(a,'input',1,'NS','trimf',[-3,-1.5,0]);
a=addmf(a,'input',1,'ZO','trimf',[-1.5,0,1.5]);
a=addmf(a,'input',1,'PS','trimf',[0,1.5,3]);
a=addmf(a,'input',1,'PM','trimf',[1.5,3,4.5]);
a=addmf(a,'input',1,'PB','trimf',[3,4.5,6]);
a=addvar(a,'input','e2',[-6 6]);
a=addmf(a,'input',2,'NB','trimf',[-6,-4.5,-3]);
a=addmf(a,'input',2,'NM','trimf',[-4.5,-3,-1.5]);
a=addmf(a,'input',2,'NS','trimf',[-3,-1.5,0]);
a=addmf(a,'input',2,'ZO','trimf',[-1.5,0,1.5]);
a=addmf(a,'input',2,'PS','trimf',[0,1.5,3]);
a=addmf(a,'input',2,'PM','trimf',[1.5,3,4.5]);
a=addmf(a,'input',2,'PB','trimf',[3,4.5,6]);
a=addvar(a,'output','u',[30 70]);
a=addmf(a,'output',1,'NB','trimf',[-4,-4,-2]);
a=addmf(a,'output',1,'NM','trimf',[-4,-2,0]);
a=addmf(a,'output',1,'NS','trimf',[-4,-2,0]);
a=addmf(a,'output',1,'ZO','trimf',[-2,0,2]);
a=addmf(a,'output',1,'PS','trimf',[0,2,4]);
a=addmf(a,'output',1,'PM','trimf',[0,2,4]);
a=addmf(a,'output',1,'PB','trimf',[2,4,4]);
a=addvar(a,'output','A1',[0.1 0.9]);
a=addmf(a,'output',2,'NB','trimf',[0.1,0.2,0.3]);
a=addmf(a,'output',2,'NM','trimf',[0.2,0.3,0.4]);
a=addmf(a,'output',2,'NS','trimf',[0.3,0.4,0.5]);
a=addmf(a,'output',2,'ZO','trimf',[0.4,0.5,0.6]);
a=addmf(a,'output',2,'PS','trimf',[0.5,0.6,0.7]);
a=addmf(a,'output',2,'PM','trimf',[0.6,0.7,0.8]);
a=addmf(a,'output',2,'PB','trimf',[0.7,0.8,0.9]);
a=addvar(a,'output','A2',[0.1 0.9]);
a=addmf(a,'output',3,'NB','trimf',[0.1,0.2,0.3]);
a=addmf(a,'output',3,'NM','trimf',[0.2,0.3,0.4]);
a=addmf(a,'output',3,'NS','trimf',[0.3,0.4,0.5]);
a=addmf(a,'output',3,'ZO','trimf',[0.4,0.5,0.6]);
a=addmf(a,'output',3,'PS','trimf',[0.5,0.6,0.7]);
a=addmf(a,'output',3,'PM','trimf',[0.6,0.7,0.8]);
a=addmf(a,'output',3,'PB','trimf',[0.7,0.8,0.9]);
%模糊规则矩阵
kk=[1 0 1 7 0 1 1
2 0 2 6 0 1 1
3 0 3 5 0 1 1
4 0 4 4 0 1 1
5 0 5 3 0 1 1
6 0 6 2 0 1 1
7 0 7 1 0 1 1
0 1 1 7 0 1 1
0 2 2 6 0 1 1
0 3 3 5 0 1 1
0 4 4 4 0 1 1
0 5 5 3 0 1 1
0 6 6 2 0 1 1
0 7 7 1 0 1 1
1 1 1 7 1 1 1
2 2 2 6 6 1 1
3 3 3 5 5 1 1
4 4 4 4 4 1 1
5 5 5 3 3 1 1
6 6 6 2 2 1 1
7 7 7 1 1 1 1];
r1=zeros(numel(size(kk)),3);k=1;
for i=1:size(kk,1)
for j=1:size(kk,2)
r1(k,:)=[i,j,kk(i,j)];
k=k+1;
end
end
[r,s]=size(r1);
r2=ones(r,2);
rulelist=[r1,r2];
a=addrule(a,kk);
%采用模糊控制器的二阶系统仿真
e1=0;e2=0;N=100;
ku1=1;ku2=1;ku3=1;
for k=1:N
%输入变量变换至论域
if e1>=6
e1=6;
elseif e1<=-6
e1=-6;
end
if e2>=6
e2=6;
elseif e2<=-6
e2=-6;
end
%模糊推理,计算出被控对象的控制输入
in=[e1 e2];
u=ku1*evalfis(in,a);
A1=ku2*evalfis(in,a);
A2=ku3*evalfis(in,a);
end
错误显示:
Total area is zero in defuzzCentroid() for output 1.
Average of the range of this output variable is used as the output value.
Total area is zero in defuzzCentroid() for output 1.
Average of the range of this output variable is used as the output value.
Total area is zero in defuzzCentroid() for output 1.
Average of the range of this output variable is used as the output value.
Total area is zero in defuzzCentroid() for output 1.
Average of the range of this output variable is used as the output value.
Total area is zero in defuzzCentroid() for output 1.
Average of the range of this output variable is used as the output value.
这是什么原因造成的,给大侠们告知,不胜感谢! |