matlab计算模糊控制表

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Matlab计算模糊控制表

实现程序如下:

clc; %清空命令窗口

clear; %清空工作空间

e=[1,0.8,0.7,0.4,0.1,0,0,0,0,0,0,0,0;

0.2,0.7,1,0.7,0.3,0,0,0,0,0,0,0,0;

0,0.1,0.3,0.7,1,0.7,0.2,0,0,0,0,0,0;

0,0,0,0,0.1,0.6,1,0,0,0,0,0,0;

0,0,0,0,0,0,1,0.6,0.1,0,0,0,0;

0,0,0,0,0,0,0.2,0.7,1,0.7,0.3,0.1,0;

0,0,0,0,0,0,0,0,0.2,0.7,1,0.7,0.3;

0,0,0,0,0,0,0,0,0.1,0.4,0.7,0.8,1] %误差的隶属度函数表,8*13的矩阵

eb=[1,0.7,0.3,0,0,0,0,0,0,0,0,0,0;

0.3,0.7,1,0.7,0.3,0,0,0,0,0,0,0,0;

0,0,0.3,0.7,1,0.7,0.3,0,0,0,0,0,0;

0,0,0,0,0.3,0.7,1,0.7,0.3,0,0,0,0;

0,0,0,0,0,0,0.3,0.7,1,0.7,0.3,0,0;

0,0,0,0,0,0,0,0,0.3,0.7,1,0.7,0.3;

0,0,0,0,0,0,0,0,0,0,0.3,0.7,1] %误差变化率的隶属度函数表,7*13的矩阵;

u=[1,0.7,0.3,0,0,0,0,0,0,0,0,0,0;

0.3,0.7,1,0.7,0.3,0,0,0,0,0,0,0,0;

0,0,0.3,0.7,1,0.7,0.3,0,0,0,0,0,0;

0,0,0,0,0.3,0.7,1,0.7,0.3,0,0,0,0;

0,0,0,0,0,0,0.3,0.7,1,0.7,0.3,0,0;

0,0,0,0,0,0,0,0,0.3,0.7,1,0.7,0.3;

0,0,0,0,0,0,0,0,0,0,0.3,0.7,1] %输出控制量u,7*13的矩阵;rulelist=[1,1,1,1,2,4,4;

1,1,1,1,2,4,4;

2,2,2,2,4,5,5;

2,2,3,4,5,6,6;

2,2,3,4,5,6,6;

3,3,4,6,6,6,6;

4,4,6,7,7,7,7;

4,4,6,7,7,7,7] %控制规则表,为8*7=56条规则;for ey=1:13 % 输入变量e的13个取值:-6——6;

for eby=1:13 %输入变量eb的13个取值:-6——6;

for ex=1:8 % 输入变量e的8个语言变量NB----PB;

for ebx=1:7 % 输入变量eb的7个语言变量NB---PB;

arule=rulelist(ex,ebx); %取一条规则;

C=u(arule,:);%取这条规则的C的隶属度;代表取一行

A=e(ex,:);%取这条规则的A的隶属度;代表取一行for i=1:13;

for j=1:13;

if (A(i)>C(1,j));

Ra(i,j)= C(1,j);

else

Ra(i,j)=A(i);

end

end

end% 算A—C的蕴含关系;

AP=zeros(1,13);

AP(1,ey)=e(ex,ey);

for i=1:13;

for j=1:13;

if (AP(j)>Ra(j,i));

GDA(j,i)= Ra(j,i);

else

GDA(j,i)=AP(j);

end

end

end%求合成运算开始的取小;

for i=1:13;

max=GDA(1,i);

for j=1:13;

if (max

max= GDA(j,i);

end

end

CPA(i)=max;

end % 合成运算取大结束;CPA算出来了;

arule=rulelist(ex,ebx); %取一条规则;

C=u(arule,:);%取这条规则的C的隶属度;代表取一行B=eb(ebx,:);%取这条规则的A的隶属度;代表取一行for i=1:13;

for j=1:13;

if (B(i)>C(1,j));

Rb(i,j)= C(1,j);

else

Rb(i,j)=B(i);

end

end

end% 算B—C的蕴含关系;

BP=zeros(1,13);

BP(1,eby)=eb(ebx,eby);

for i=1:13;

for j=1:13;

if (BP(j)>Rb(j,i));

GDB(j,i)= Rb(j,i);

else

GDB(j,i)=BP(j);

end

end

end%求合成运算开始的取小;

for i=1:13;

max=GDB(1,i);

for j=1:13;

if (max

max= GDB(j,i);

end

end

CPB(i)=max;

end; % 合成运算取大结束;CPB算出来了;

相关文档
最新文档