模糊控制实验演示教学

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

中南大学模糊控制课程实验报告学生姓名:彭雄威指导教师:袁艳学院:信息科学与工程学院学号:114611167实验一:本系统设计基于MATLAB图形模糊推理系统,设计步骤如下:打开MATLAB,输入指令fuzzy,打开模糊逻辑工具箱的图形用户界面窗口,新建一个Mamdani模糊推理系统。(1)增加一个输入变量,将输入变量命名为E、Ec,将输出变量命名U。这样就建立了一个两输入单输出的模糊推理系统。如图1.1所示。图1.1增加一个输入变量(2)设计模糊化模块:设计隶属度函数论域范围图3.2设计水位误差E模块3.3设计水位误差Ec模块图3.4设计水位输出U模块(4)模糊控制器的规则设计(5)通过观察器观察规则情况在菜单view中的rules和surface选项分别对应得是规则观测器和曲面观测器。图3.7规则观测器图3.6曲面观测器(6)保存编辑好的FIS文件实验二:利用MATLAB软件的M文件编辑器和实验一所生成的fuzzf.FIS文件,在M文件编辑器中输入:a=readfis('fuzzf');evalfis([-0.5,-0.07;-0.5,0;-0.5,0.07;0,-0.07;0,0;0,0.07;0.5,-0.07;0.5,0;0.5,0.07],a)便可得fuzzf.FIS文件的模糊控制查询表,其中的数据在水位误差E的论域为[-11],误差变化Ec的论域为[-0.10.1]内可以任意取值。a=readfis('fuzzf')a=name:'fuzzf'type:'mamdani'andMethod:'min'orMethod:'max'defuzzMethod:'centroid'impMethod:'min'aggMethod:'max'input:[1x2struct]output:[1x1struct]rule:[1x5struct]a=readfis('fuzzf');evalfis([-0.5,-0.07;-0.5,0;-0.5,0.07;0,-0.07;0,0;0,0.07;0.5,-0.07;0.5,0;0.5,0.07],a)ans=-0.2000-0.4444-0.46670.1363-0.0014-0.22710.40000.44120.1333实验三利用MATLAB软件的M文件编辑器(也可选择C语言)完成模糊控制查询表的计算。注意:全部工作都由程序实现,不利用FIS文件,不使用Fuzzy工具箱,包括模糊关系矩阵的求取及模糊推理、模糊判决。表1偏差E的赋值表eE-6-5-4-3-2-10123456NB10.80.70.40.40.10000000NM0.20.710.70.300000000NS00.10.30.710.70.2000000NO00000.10.61000000PO00000010.60.10000PS0000000.20.710.70.30.10PM000000000.20.710.70.3PB000000000.10.40.70.81表2偏差变化率Ec的赋值表ecEc-6-5-4-3-2-10123456NB10.70.30000000000NM0.30.710.70.300000000NS000.30.710.70.3000000O00000.30.710.70.30000PS0000000.30.710.70.300PM000000000.30.710.70.3PB00000000000.30.71表3推理语言规则表EcENBNMNSOPSPMPBNBPBPBPBPBPMOONMPBPBPBPBPMOONSPMPMPMPMONSNSNOPMPMPSONSNMNMPOPMPMPSONSNMNMPSPSPSONMNMNMNMPMOONMNSNSNSNSPBOONMNSNSNSNS表4控制量U的赋值表U-6-5-4-3-2-10123456NB10.70.30000000000NM0.30.710.70.300000000NS000.30.710.70.3000000O00000.30.710.70.30000PS0000000.30.710.70.300PM000000000.30.710.70.3PB00000000000.30.71程序如下: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*13EC=[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*13U=[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*13rulelist=[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*7foriii=1:13%偏差E的模糊值控制forjjj=1:13%偏差率EC的模糊值控制forii=1:8%偏差E的模糊规则控制forjj=1:7%偏差变化率EC的模糊规则控制A_rulelist=rulelist(ii,jj);%查模糊规则表%******计算C1A'************A=E(ii,:);%取A'C_A=U(A_rulelist,:);%取Cifori=1:13%求R1Aforj=1:13if(A(i)C_A(1,j))Ra(i,j)=C_A(1,j);elseRa(i,j)=A(i);endendendAA=zeros(1,13);%取AA=A'如AA=[1,0,0,0,0,0,0,0,0,0,0,0,0];%AA(1,iii)=E(ii,iii);AA(1,iii)=1;fori=1:13%先取小forj=1:13if(AA(j)Ra(j,i))A_qux(j,i)=Ra(j,i);elseA_qux(j,i)=AA(j);endendendfori=1:13%再取大,,,求和CiAmax=A_qux(1,i);forj=1:13if(maxA_qux(j,i))max=A_qux(j,i);endendCiA(i)=max;end%********CiA计算完毕*********%*******计算CiB'*************B=EC(jj,:);%取B'???C_B=U(A_rulelist,:);%取Ci???fori=1:13%求R1Bforj=1:13if(B(1,i)C_B(1,j))Rb(i,j)=C_B(1,j);elseRb(i,j)=B(1,i);endendendBB=zeros(1,13);%取BB=B'如BB=[1,0,0,0,0,0,0,0,0,0,0,0,0];%BB(1,jjj)=EC(jj,jjj);BB(1,jjj)=1;fori=1:13%先取小forj=1:13if(BB(j)Rb(j,i))B_qux(j,i)=Rb(j,i);elseB_qux(j,i)=BB(j);endendendfori=1:13%再取大,,,求和CiAmax=B_qux(1,i);forj=1:13if(maxB_qux(j,i))max=B_qux(j,i);endendCiB(i)=max;end%*******计算CiB'完毕****%*******计算C1'=CiA'交CiB'*********fori=1:13ifCiA(i)CiB(i)Ci(i)=CiB(i);elseCi(i)=CiA(i);endend%*******计算C1'完毕************C((ii-1)*7+jj,:)=Ci;%将Ci存到数组C中,C是56*13的数组endend%根据式Ui=C'=C1'并C2'并……并3'fori=1:13max=C(1,i);forj=1:56if(maxC(j,i))max=C(j,i);endendUi(i)=max;end%用重心法进行解模糊运算,并映射为实际的控制量sum_fenz=0;sum_fenm=0;fori=1:13sum_fenz=sum_fenz+(i-7)*Ui(i);sum_fenm=sum_fenm+Ui(i);endcore=sum_fenz/sum_fenm;U_control(iii,jjj)=core;endendU_control=round(U_control.*10000)/10000;%对控制量保留小数点后两位U_control计算结果:实验四控制系统仿真实验。利用MATLAB的SIMULINK设计一个控制系统,在库中找到所需的各模块,连接各模块,启动仿真,显示输出曲线,观察控制性能,不理想时适当修改有关参数或控制规则,获得满意的控制效果。(对象采用二阶以上)被控对象模型为:2553ss++simulink结构图如下:得到如下曲线:

1 / 14
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功