资源描述:
《matlab计算模糊控制表》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、可编辑版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
2、,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=[
3、1,0.7,0.3,0,0,0,0,0,0,0,0,0,0;Word完美格式可编辑版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,
4、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条规则;forey=1:13%输入变量e的13个取值:-6——6;foreby=1:13%输入变量eb的13个取值:-6——6;forex=1:8%输入变量e的8个语言变量NB----PB;forebx=1:7%输入变量eb的7个语言变量NB---PB;arule=rulelist(ex,ebx);%取一条规则;C=u(arule,:);%取这条规则的C的隶属度;代表取一行Word完美格式可编辑版A=
5、e(ex,:);%取这条规则的A的隶属度;代表取一行fori=1:13;forj=1:13;if(A(i)>C(1,j));Ra(i,j)=C(1,j);elseRa(i,j)=A(i);endendend%算A—C的蕴含关系;AP=zeros(1,13);AP(1,ey)=e(ex,ey);fori=1:13;forj=1:13;if(AP(j)>Ra(j,i));GDA(j,i)=Ra(j,i);elseGDA(j,i)=AP(j);endendend%求合成运算开始的取小;Word完美格式可编辑版fori=1:13;max=GDA(1,i);forj=1:13;if(max6、j,i))max=GDA(j,i);endendCPA(i)=max;end%合成运算取大结束;CPA算出来了;arule=rulelist(ex,ebx);%取一条规则;C=u(arule,:);%取这条规则的C的隶属度;代表取一行B=eb(ebx,:);%取这条规则的A的隶属度;代表取一行fori=1:13;forj=1:13;if(B(i)>C(1,j));Rb(i,j)=C(1,j);elseRb(i,j)=B(i);endendend%算B—C的蕴含关系;Word完美格式可编辑版BP=zeros(1,13);BP(1,eby)=eb(ebx,eby);fori=1:13;forj
7、=1:13;if(BP(j)>Rb(j,i));GDB(j,i)=Rb(j,i);elseGDB(j,i)=BP(j);endendend%求合成运算开始的取小;fori=1:13;max=GDB(1,i);forj=1:13;if(max