智慧型控制大作業
第一次大作業
姓名: 周慶強
學號: 1140810106
哈爾濱工業大學
2023年5月25日
對乙個系統[\\right)=\\frac', 'altimg': '', 'w': '125', 'h':
'43', 'omath': 'gs=110s+1'}],假設給系統乙個階躍值r=30,取樣時間為1s,系統的初始值為r(0)=0,利用常規的模糊控制器對系統進行控制。
在**系統中,不需要考慮訊號的a/d和d/a轉換,模糊控制系統框圖如下:
將偏差e,即當前位置-目標目標,作為觀察量(輸入量)1,%將偏差的變化量ec,即e(t)-e(t-1),作為觀察量(輸入量)2,選取閥門開度u為控制量。
將偏差e劃分為5個模糊集,負大(nb)、負小(ns)、零(zo)、正小(ps)、正大(pb),e為負表示當前水位低於目標水位,e為正表示當前水位高於目標水位。設定e的取值範圍為[-3,3],隸屬度函式如下。
同理,將偏差的變化量ec劃分為5個模糊集,負大(nb)、負小(ns)、零(zo)、正小(ps)、正大(pb),ec為負表示該時刻水位比上一時刻水位小,ec為鄭表示該時刻水位比上一時刻水位大,。設定ec的取值範圍為[-3,3],隸屬度函式如下。
同樣將控制量u劃分為5個模糊集,負大(nb)、負小(ns)、零(zo)、正小(ps)、正大(pb),u為負表示減小控制量,u為正表示增大控制量。設定u的取值範圍為[-4,4],隸屬度函式如下。
模糊規則的制定是模糊控制的核心內容,控制效能的好壞很大程度上由模糊規則決定,本文主要是根據經驗來制定相應的規則。
將上述用語言描述的規則轉化為「if a ,then b」的語句如下:
1. if (e is nb) and (ec is nb) then (u is pb) 。
2. if (e is nb) and (ec is ns) then (u is pb) 。
3. if (e is nb) and (ec is zo) then (u is pb) 。
4. if (e is nb) and (ec is ps) then (u is pb) 。
5. if (e is nb) and (ec is pb) then (u is pb) 。
6. if (e is ns) and (ec is nb) then (u is pb) 。
7. if (e is ns) and (ec is ns) then (u is pb) 。
8. if (e is ns) and (ec is zo) then (u is ps) 。
9. if (e is ns) and (ec is ps) then (u is ps) 。
10. if (e is ns) and (ec is pb) then (u is zo) 。
11. if (e is zo) and (ec is nb) then (u is pb) 。
12. if (e is zo) and (ec is ns) then (u is ps) 。
13. if (e is zo) and (ec is zo) then (u is zo) 。
14. if (e is zo) and (ec is ps) then (u is ns) 。
15. if (e is zo) and (ec is pb) then (u is nb) 。
16. if (e is ps) and (ec is nb) then (u is zo) 。
17. if (e is ps) and (ec is ns) then (u is ps) 。
18. if (e is ps) and (ec is zo) then (u is ns) 。
19. if (e is ps) and (ec is ps) then (u is nb) 。
20. if (e is ps) and (ec is pb) then (u is nb) 。
21. if (e is pb) and (ec is nb) then (u is nb) 。
22. if (e is pb) and (ec is ns) then (u is nb) 。
23. if (e is pb) and (ec is zo) then (u is nb) 。
24. if (e is pb) and (ec is ps) then (u is nb) 。
25. if (e is pb) and (ec is pb) then (u is nb) 。
我們最終需要獲得的控制量u即為模糊控制的輸出,u可由兩個輸入量(偏差矩陣e和偏差矩陣ec)和模糊關係矩陣r合成得到。
[\\right)r', 'altimg': '', 'w': '154', 'h': '21', 'omath': 'u=e and ecr'}]
根據制定的模糊規則,通過相應的模糊集合運算,可得到模糊關係集合r。r定義為:
[_=\\left(_and_}\\right)→_', 'altimg': '', 'w': '169', 'h':
'25', 'omath': 'ri=eiandeci→ui'}]
即:[_=___)→_}', 'altimg': '', 'w': '141', 'h': '29', 'omath': 'μri=μ(aiandbi)→ui'}]
輸出模糊量:
[_=\\left(__}\\right)_', 'altimg': '', 'w': '168', 'h':
'25', 'omath': 'ui=ei and eciri'}]
我們模糊決策得到的控制量u是乙個矩陣,並不能直接應用在工程上,因此需要將u解釋為實際中的特定行為,即反模糊化操作。目前常用的反模糊化方法有以下幾種:
(1)最大隸屬度法----計算簡單控制要求不高場合
(2)重心法----輸出更平滑
(3)加權平均法----工業上應用最廣泛
本設計中採用第三種方法:加權平均法。
系統結構如圖:
通過matlab整合的模糊控制模組,我們能夠更加方便地對應偏差e、偏差量ec和控制量u的關係,並可以調節e和ec在不同值下u的對應輸出。
在系統中,發現隨著時間的推移,系統快速到達距離標準位置很近的25左右,繼而出現波動情況。分析出現這種現象的原因是模糊控制的調整太大,需要進行自適應調整,以便系統在到達e接近與0的情況下,仍能繼續接近標準位置。
老師,最近有些事,沒時間做自適應調整了,對不起啊。
clear;clc;
%對接收階躍訊號的系統進行模糊控制
%% 構建模糊控制器
a = newfis('fuzzy tank');
%輸入量e的模糊化
a = addvar(a,'input','e',[-3,3]); %將偏差e,即當前位置-目標目標,作為觀察量(輸入量)
a = addmf(a,'input',1,'nb','zmf',[-3,-1]);
a =addmf(a,'input',1,'ns','trimf',[-3,-1,1]);
a =addmf(a,'input',1,'zo','trimf',[-2,0,2]);
a =addmf(a,'input',1,'ps','trimf',[-1,1,3]);
a = addmf(a,'input',1,'pb','smf',[1,3]);
%輸入量ec的模糊化
a = addvar(a,'input','ec',[-3,3]); %將偏差的變化量ec,即e(t)-e(t-1),作為觀察量(輸入量)
a = addmf(a,'input',2,'nb','zmf',[-3,-1]);
a =addmf(a,'input',2,'ns','trimf',[-3,-1,1]);
a =addmf(a,'input',2,'zo','trimf',[-2,0,2]);
a =addmf(a,'input',2,'ps','trimf',[-1,1,3]);
a = addmf(a,'input',2,'pb','smf',[1,3]);
%輸出量的模糊化
a = addvar(a,'output','u',[-4,4]);%選取閥門開度u為控制量
a = addmf(a,'output',1,'nb','zmf',[-4,-2]);
a =addmf(a,'output',1,'ns','trimf',[-4,-2,0]);
a =addmf(a,'output',1,'zo','trimf',[-2,0,2]);
a =addmf(a,'output',1,'ps','trimf',[0,2,4]);
a = addmf(a,'output',1,'pb','smf',[2,4]);
%建立模糊規則
rulelist=[1 1 5 1 1
1 2 5 1 1
1 3 5 1 1
1 4 5 1 1
1 5 5 1 1
2 1 5 1 1
2 2 5 1 1
2 3 4 1 1
2 4 4 1 1
2 5 3 1 1
3 1 5 1 1
3 2 4 1 1
3 3 3 1 1
3 4 2 1 1
3 5 1 1 1
4 1 3 1 1
4 2 4 1 1
4 3 2 1 1
4 4 1 1 1
4 5 1 1 1
5 1 1 1 1
5 2 1 1 1
5 3 1 1 1
5 4 1 1 1
5 5 1 1 1];
a = addrule(a,rulelist);
%設定反模糊化演算法
a1 = setfis(a,'defuzzmethod','mom');
writefis(a1,'tank');
a2 = readfis('tank'); %可代入計算的
figure(1);
plotfis(a2);
figure(2);
plotmf(a,'input',1);
figure(3);
plotmf(a,'input',2);
figure(4);
plotmf(a,'output',1);
%展示e、ec和u的對應關係
showrule(a);
ruleview('tank');
%% 實時調控
r_t=0;%初始值r(0)=0;
r_tf=0;
ulist=0;
r_aim=30;%目標值
n=50;%進行100次校核
record=zeros(1,n);%記錄r的變化
for i=1:n
r_t=r_tf+ulist;
e=(r_t-r_aim)*0.1;%獲取差值並轉化為偏差
ec=(r_t-r_tf)*0.75;%偏差的變化量的k=0.75;
r_tf=r_t;
最優化方法的matlab實現
在生活和工作中,人們對於同乙個問題往往會提出多個解決方案,並通過各方面的論證從中提取最佳方案。最優化方法就是專門研究如何從多個方案中科學合理地提取出最佳方案的科學。由於優化問題無所不在,目前最優化方法的應用和研究已經深入到了生產和科研的各個領域,如土木工程 機械工程 化學工程 運輸排程 生產控制 經...
判別分析的MATLAB實現案例
讀取 examp10 中資料,進行距離判別 讀取資料 讀取檔案 examp10 的第 1 個工作表中 c2 f51 範圍的資料,即全部樣本資料,包括未判企業 sample xlsread examp10 c2 f51 讀取檔案 examp10 的第 1 個工作表中 c2 f47 範圍的資料,即已知組...
模糊控制在燒結爐溫控系統中的應用
0 引言 真空脫蠟燒結一體爐可一次性完成脫膠 燒結 冷卻和收取成型劑的全套工藝流程。其在傳統燒結爐結構的基礎上增加了乙個石墨內膽,並採用低壓載氣脫蠟工藝,經收蠟裝置分離出粘結 成型 劑後,餘氣以多種方式排出。由於採用了上述工藝方式,成型劑在爐內不會接觸冷的表面及在爐內積存,也不會汙染保溫層和發熱體。...