资源描述
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条规则;forey=1:13%输入变量e的13个取值:-66;foreby=1:13%输入变量eb的13个取值:-66;forex=1:8%输入变量e的8个语言变量NB-PB;forebx=1:7%输入变量eb的7个语言变量NB-PB;arule=rulelist(ex,ebx);%取一条规则;C=u(arule,:);%取这条规则的C的隶属度;代表取一行A=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%算AC的蕴含关系;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%求合成运算开始的取小;fori=1:13;max=GDA(1,i);forj=1:13;if(maxC(1,j);Rb(i,j)=C(1,j);elseRb(i,j)=B(i);endendend%算BC的蕴含关系;BP=zeros(1,13);BP(1,eby)=eb(ebx,eby);fori=1:13;forj=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(maxCPB(i)CP(i)=CPB(i);elseCP(i)=CPA(i);endend%第一个CP1计算结束;将来C是56*13的矩阵;CB(ex-1)*7+ebx,:)=CP;endendfori=1:13;max=CB(1,i);forj=1:56;if(maxCB(j,i)max=CB(j,i);endendU(i)=max;end%56个CP整理结束;sumFZ=0;sumFM=0;fori=1:13;sumFZ=sumFZ+(i-7)*U(i);sumFM=sumFM+U(i);endcore=sumFZ/sumFM;UB(ey,eby)=core;%一个控制表中的元素算出来了endendUB=round(UB*100)/100;%保留两位display(UB);程序运行结果如下:UE=Colunns1thiough3-5.3500-B.2400-5.3500-5.2;ao-5.3500-6,2400-1.69Q0-4.2000-5.0000-4.9500-5.0000-1.9500-5.0000-4.9500-3.S600-3.7)00-4.6900-4.5200-4,6900-4.5200-4.6900-4.5200-3.0500-2.9300-4.2600-4.2600-4.2S00-4,2500-4-2600-4.2600-2.9300-2.2900-4,mo-4.itiQQ-X7800-3,750Q-3,4700-3.4200-2+43QQ-l.7?(J0-4.aooo4.0000-3.3600-3.0800-2.J700-2.J2C0-L5O&0-1.0500-3.5900-3.5500-5.9305-2.SOW-0.9600-G.510000.5100-2.9200-3.9200-2.3300-1.9100-0.2600L.0500LGOOD2.1200-L3I00-1.79Q0-0.57Q(J-0.3100Q.440QI.79QQ2,2QQ3200-loaoo-1.0000D.2500o.9ao1.42002.29002-93004,2eaa-0.5800-0.64000.69001.42001.94002.93003.05004.5200-0.2300-0.2100L1200L7&002.36003.7100XSflOO4.950000L29QQZ00002.71004.26001.SBOO5,2400Columns9through13-2.7100-2.0000-1.290000-2,3500-1.7900-112006240Q0,2300-I.9400-L450O-0.6000o.6ao0.5S0C-1.4200-0.9400-0.2500l.OQOO1.0000-0.4400-0.04000.16001.60001.63000.测r9lQQ2.33052h92002.92000.960D2.60002.93003.55003.59002.4:003.0BOO3.3A004.00004.00003.47003.76003.78004.00004.00004.26004.26004.26004*25004.26004.颐。4.5200j.cm4.520Q4.cms.mo4.9S00s.oooo4.9500s.oooo5.35005.21005.35005.24005.3500程序结果分析:(孙增圻)综合MATLAB程序运算出来的结果和智能控制理论与技术第二版上的结果,完全一致,证明程序运算结果正确!
展开阅读全文