水箱水位模糊控制系统设计
一.在MATLAB命令窗口中输入sltank,便可打开如图所示的模型窗口。
图1 sltank仿真图
(1)打开MATLAB,输入指令fuzzy,打开模糊逻辑工具箱的图形用户界面
窗口,新建一个Mamdani模糊推理系统。
(2)增加一个输入变量,将输入变量命名为水位误差、误差变化,将输出
变量命名为阀门开关速度。这样就建立了一个两输入单输出的模糊推理系统,保存为shuiwei1。
图2 增加一个输入变量
(3)设计模糊化模块;设水位误差level的论域为[2、95 3、05],误差变
化率rate的论域为[-0、2 0、2];
智能控制及MATLAB实现—水箱液位模糊控制仿真设计
两个输入量的模糊集为level设为为7个,rate设为5个:其中水位误差
level定为NB、NM、NS、ZE、PS、PM、PB;参数分别为[0、01 2、95]、[0、01 2、97],[0、01 2、99]、[0、01 3]、[0、01 3、01]、[0、01 3、03]、[0、01 3、05],隶属度均为高斯函数;
图3 输入量level的参数设定
误差变化率rate分别为负大,负小,不变,正小,正大。参数分别为,[0、
03 -0、2]、[0、03 -0、1]、[0、03 0]、[0、03 0、1]、[0、03 -0、2],隶属度函数均为高斯函数。
图4 误差变化率rate的参数设定
智能控制及MATLAB实现—水箱液位模糊控制仿真设计
阀门的开关速度设为七个等级:快关,中关,慢关,不动,慢开,中开,快开,
其论域为[2、95 3、05]。参数分别为;[2、94 2、95 2、96]、[2、965 2、97 2、975]、[2、99 2、99 2、995]、[2、999 3 3、001]、[3、005 3、01 3、015]、[3、02 3、03 3、035]、[3、04 3、05 3、06],隶属函数为三角形函数。
图5
(4)设计模糊规则
打开Ruel Editor
输出量valve的参数设定窗口,通过选择添加模糊规则;
负大) then (valve is 负小) then (valve is 不变) then (valve is 正小) then (valve is 正大) then (valve is 负大) then (valve is 负小) then (valve is 不变) then (valve is 正小) then (valve is 正大) then (valve is 负大) then (valve is 负小) then (valve is 不变) then (valve is 正小) then (valve is 正大) then (valve is 负大) then (valve is 负小) then (valve is 不变) then (valve is
快关) (1) 快关) (1) 快关) (1) 中关) (1) 不动) (1) 快关) (1) 快关) (1) 快关) (1) 中关) (1) 不动) (1) 中关) (1) 中关) (1) 中关) (1) 不动) (1) 慢开) (1) 中关) (1) 慢关) (1) 不动) (1)
1)If (level is NB) and (rate is 2)If (level is NB) and (rate is 3)If (level is NB) and (rate is 4)If (level is NB) and (rate is 5)If (level is NB) and (rate is 6)If (level is NM) and (rate is 7)If (level is NM) and (rate is 8)If (level is NM) and (rate is 9)If (level is NM) and (rate is 10)If (level is NM) and (rate is 11)If (level is NS) and (rate is 12)If (level is NS) and (rate is 13)If (level is NS) and (rate is 14)If (level is NS) and (rate is 15)If (level is NS) and (rate is 16)If (level is ZE) and (rate is 17)If (level is ZE) and (rate is 18)If (level is ZE) and (rate is
智能控制及MATLAB实现—水箱液位模糊控制仿真设计19)If (level is ZE) and (rate is 20)If (level is ZE) and (rate is 21)If (level is PS) and (rate is 22)If (level is PS) and (rate is 23)If (level is PS) and (rate is 24)If (level is PS) and (rate is 25)If (level is PS) and (rate is 26)If (level is PM) and (rate is 27)If (level is PM) and (rate is 28)If (level is PM) and (rate is 29)If (level is PM) and (rate is 30)If (level is PM) and (rate is 31)If (level is PB) and (rate is 32)If (level is PB) and (rate is 33)If (level is PB) and (rate is 34)If (level is PB) and (rate is 35)If (level is PB) and (rate is
这35条模糊控制规则的权重都为
正小) then (valve is 正大) then (valve is 负大) then (valve is 负小) then (valve is 不变) then (valve is 正小) then (valve is 正大) then (valve is 负大) then (valve is 负小) then (valve is 不变) then (valve is 正小) then (valve is 正大) then (valve is 负大) then (valve is 负小) then (valve is 不变) then (valve is 正小) then (valve is 正大) then (valve is 1、
慢开) (1) 中开) (1) 慢关) (1) 不动) (1) 中开) (1) 中开) (1) 中开) (1) 不动) (1) 中开) (1) 快开) (1) 快开) (1) 快开) (1) 不动) (1) 中开) (1) 快开) (1) 快开) (1) 快开) (1)
图6 模糊控制规则的设定
(5)利用编辑器的 to Workspace, 将当前的模糊推理系统,以shuiwei1保存
到工作空间中。
(6)在如图1所示的Simulink仿真系统中,打开Fuzzy Logic Controller
模糊逻辑控制器模块对话框,在其FIS Structure参数对话框中输入:shuiwei1。
智能控制及MATLAB实现—水箱液位模糊控制仿真设计
(7)在如图1所示的Simulink系统中,打开仿真参数设置窗口,正确设置仿真参数后,启动仿真便可瞧到水位变化曲线。
图7 水位变化曲线
通过曲面观察器也可以清晰的瞧见水箱液位模糊推理的输入输出关系。
图8 Surface Viewer
总结:随着科学技术的发展,智能控制技术必会日趋完善,并且能够在多领域应用。
因篇幅问题不能全部显示,请点此查看更多更全内容