《matlab计算模糊控制表(共8页).doc》由会员分享,可在线阅读,更多相关《matlab计算模糊控制表(共8页).doc(8页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
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.
2、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 %误差变化
3、率的隶属度函数表,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
4、,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个取值:-66; for eby=1:13 %输入变量eb的13个取值:-66; for ex=1:8 % 输入变量e的8个语言变量NB-PB; for ebx=1:7 % 输入变量eb的7个语言变量NB-PB;arule=rulelist(ex,ebx); %取一条规则;C=u(arule,:);%取这条规则的C的
5、隶属度;代表取一行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); endendend% 算AC的蕴含关系;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); endendend%求合成运算开始的取小;for i=1:13;max=GDA(1,i);for j=1:1
6、3; if (maxC(1,j); Rb(i,j)= C(1,j); else Rb(i,j)=B(i); endendend% 算BC的蕴含关系;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); endendend%求合成运算开始的取小;for i=1:13;max=GDB(1,i);for j=1:13; if (maxCPB(i)CP(i)=CPB(i);elseCP(i)=CPA(i);endend %
7、 第一个CP1计算结束;将来C是56*13的矩阵;CB(ex-1)*7+ebx,:)=CP;endendfor i=1:13; max=CB(1,i);for j=1:56;if(maxCB(j,i) max=CB(j,i);endendU(i)=max;end %56个CP整理结束;sumFZ=0;sumFM=0;for i=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);程序运行结果如下:程序结果分析:综合MATLAB程序运算出来的结果和智能控制理论与技术(孙增圻)第二版上的结果,完全一致,证明程序运算结果正确! 专心-专注-专业