多變量系統(tǒng)辨識matlab程序_第1頁
多變量系統(tǒng)辨識matlab程序_第2頁
多變量系統(tǒng)辨識matlab程序_第3頁
多變量系統(tǒng)辨識matlab程序_第4頁
多變量系統(tǒng)辨識matlab程序_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、多變量系統(tǒng)辨識matlab程序i=jI三my(i)=0.05129*u1_1+0.0418;u1_3=u1_2;u1_2=u1_1;u1_1;u2_3=u2_2;u2_2=u2_1;u2_1;y_3=y_2;y_2=y_1;y_1=y(i);r_3=r_2;r_2=r_1;r_1=r(i) ; end; plot(time,y,b); holdon; xi=y; ; savesub.y(i)=0.05129*u1_1+0.0418*u2_1+0.6386*y_1+0.06268*u1_2+0.0346*u2_2 -0.1179*y_2-0.004184*u1_3-0.00218*u2_3+0.

2、006738*y_3+0.091*r_1-0.114*r _2+0.0509*r_3;u1_3=u1_2;u1_2=u1_1;u1_1=u1(i);u2_3=u2_2;u2_2=u2_1;u2_1=u2(i);y_3=y_2;y_2=y_1;y_1=y(i);r_3=r_2;r_2=r_1;r_1=r(i);endplot(time,y,b)hold onxi=y;save sub.txt xi - ascii程序5clear%CRA模型基于模型階次遞增的辨識。clcclose allz=load(sub.txt);u1=load(prbs1.txt);u2=load(prbs2.txt);f

3、or i=1:1:100H(i,:) = u1(20+i-1) u2(20+i-1) -1*z(20+i-1);endtheta=(1e-3)*ones(3,1);P=(1e8)*eye(3);for i=1:1:100K=P*H(i,:)./(H(i,:)*P*H(i,:)+1);theta二theta+K*(z(i+20)-H(i,:)*theta);P=(eye(3)-K*H(i,:)*P;endtheta1二thetaH1=H;J(1) 二 (z(21:120)-H1*theta1)*(z(21:120)-H1*theta1);ZZ=inv(H1*H1);%*for n=2:1:10f

4、or i=1:1:100H2(i,:) = u1(20+i-n) u2(20+i-n) -1*z(20+i-n);endB=inv(H2*H2-H2*H1*ZZ*H1*H2);A=ZZ*H1*H2*B;theta2二B*H2*(z(21:120)-H1*theta1);theta1=theta1-A*H2*(z(21:120)-H1*theta1);theta1=theta1;theta2ZZ1=ZZ+A*H2*H1*ZZ -A;ZZ2=-A B;ZZ=ZZ1;ZZ2;J(n) = (z(21:120)-H1*theta1)*(z(21:120)-H1*theta1);F(n-1) = (J(

5、n-1)-J(n)/2)/(J(n)/(100-2*n);time(n-1)=n;TEST(n-1)=3;endplot(time,F,r-*,time,TEST)title(F統(tǒng)計值隨系統(tǒng)階次的變化)xlabel(系統(tǒng)階次)ylabel(F 統(tǒng)計值)legend(F(2(n_2-n_1),100-2n_2),F(2,100)程序6clear%*CAR模型最佳辨識的驗證,同時獲取CARMA模型的殘差序 列,存于error.txt中。clcu1=load(prbs1.txt);u2=load(prbs2.txt);z=load(sub.txt)u1_6=0;u1_5=0;u1_4=0;u1_1=

6、0;u1_2=0;u1_3=0;u2_6=0;u2_5=0;u2_4=0;u2_1=0;u2_2=0;u2_3=0;y_6=0;y_5=0;y_4=0;y_1=0;y_2=0;y_3=0;r_1=0;r_2=0;r_3=0;for i=1:1:120time(i)=i;y(i)=0.0496*u1_1+0.0417*u2_1-0.6724*y_1+0.1300*u1_2+0.0902*u2_2-0. 4219*y_2+0.1352*u1_3+0.0911*u2_3-0.1887*y_3+0.1032*u1_4+0.0707*u2_4+- 0.0188*y_4+0.0639*u1_5+0.040

7、1*u2_5+00.1125*y_5+ 0.0210*u1_6+0.0132*u2 _6-0.0101*y_6;u1_6=u1_5;u1_5=u1_4;u1_4=u1_3;u1_3=u1_2;u1_2=u1_1;u1_1=u1(i);u2_6=u2_5;u2_5=u2_4;u2_4=u2_3;u2_3=u2_2;u2_2=u2_1;u2_1=u2(i);y_6=y_5;y_5=y_4;y_4=y_3;y_3=y_2;y_2=y_1;y_1=y(i);plot(time,y,g)hold :ne-z-y ;save error.txt e - ascii程序7clear%子模型基于模型階次遞增的

8、辨識。clcclose allz-load(sub.txt);u1-loadCprbs1.txt);u2-loadCprbs2.txt);e-load(error.txt);for i-1:1:100endtheta-(1e-3)*ones(4,1);P-(1e8)*eye(4);for i-1:1:100K-P*H(i,:)./(H(i,:)*P*H(i,:)+1)theta二theta+K*(z(i+20)-H(i,:)*theta);P=(eye(4)-K*H(i,:)*P;endthetal二thetaH1=H;J(1) 二 (z(21:120)-H1*theta1)*(z(21:12

9、0)-H1*theta1);ZZ=inv(H1*H1);%*for n=2:1:10for i=1:1:100H2(i,:) = u1(20+i-n) u2(20+i-n) -1*z(20+i-n) e(20+i-n);endB=inv(H2*H2-H2*H1*ZZ*H1*H2);A=ZZ*H1*H2*B;theta2二B*H2*(z(21:120)-H1*theta1);theta1=theta1-A*H2*(z(21:120)-H1*theta1);theta1=theta1;theta2ZZ1=ZZ+A*H2*H1*ZZ -A;ZZ2=-A B;ZZ=ZZ1;ZZ2;H1=H1 H2;J

10、(n) = (z(21:120)-H1*theta1)*(z(21:120)-H1*theta1);F(n-1) = (J(n-1)-J(n)/3)/(J(n)/(100-3*n);time(n-1)=n;TEST(n-1)=3;endplot(time,F,r-*,time,TEST)title(F統(tǒng)計值隨系統(tǒng)階次的變化)xlabel(系統(tǒng)階次)ylabel(F 統(tǒng)計值)legend(F(2(n_2-n_1),100-2n_2),F(2,100)程序8clear%*CARMA模型最佳辨識的驗證,同時獲取子子模型的輸出, 分別存于 ssub1.txt 與 ssub2.txt 中。clcu1=l

11、oad(prbs1.txt);u2=load(prbs2.txt);z=load(sub.txt);e=load(error.txt);u1_1=0;u1_2=0;u1_3=0;u1_4=0;y_1=O;y_2=0;y_3=0;y_4=0;e_4=0;e_1=0;e_2=0;e_3=0;y1_1=0;y1_2=0;y1_3=0;y1_4=0;y2_1=0;y2_2=0;y2_3=0;y2_4=0;r_1=0;r_2=0;r_3=0;for i=1:1:120time(i)=i;y(i)=0.0507*u1_1+0.0426*u2_1-0.8329*y_1+0.2335*e_1+0.1383*u

12、1_2+0. 0974*u2_2-0.2791*y_2-0.1006*e_2+0.1437*u1_3+0.0956*u2_3+0.4623*y_3-0. 7050*e_3+0.0654*u1_4+0.0400*u2_4-0.0736*y_4-0.0502*e_4;y1(i)=0.0507*u1_1-0.8329*y1_1+0.1383*u1_2-0.2791*y1_2+0.1437*u1_3 +0.4623*y1_3+0.0654*u1_4-0.0736*y1_4;y2(i)=0.0426*u2_1-0.8329*y2_1+0.0974*u2_2-0.2791*y2_2+0.0956*u2_3

13、 +0.4623*y2_3+0.0400*u2_4-0.0736*y2_4;u1_4=u1_3;u1_3=u1_2;u1_2=u1_1;u1_1=u1(i);u2_4=u2_3;u2_3=u2_2;u2_2=u2_1;u2_1=u2(i);y_4=y_3;y_3=y_2;y_2=y_1;y_1=y(i);e_4=e_3;e_3=e_2;e_2=e_1;e_1=e(i);y1_4=y1_3;y1_3=y1_2;y1_2=y1_1;y1_1=y1(i);y2_4=y2_3;y2_3=y2_2;y2_2=y2_1;y2_1=y2(i);plot(time,y,m,time,y1+y2,k)hold

14、onsave ssub1.txt y1 -asciisave ssub2.txt y2 - ascii程序9clear%子子模型1的基于階次遞增的辨識。clc% close allz=load(ssub1.txt);u=load(prbs1.txt);for i=1:1:100H(i,:) = u(20+i-1) -1*z(20+i-1);endtheta=(1e-3)*ones(2,1);P=(1e8)*eye(2);for i=1:1:100K=P*H(i,:)./(H(i,:)*P*H(i,:)+1);theta二theta+K*(z(i+20)-H(i,:)*theta);P=(eye

15、(2)-K*H(i,:)*P;endthetal二thetasigmaF(1) = (z(21:120)-H1*theta1)*(z(21:120)-H1*theta1)/100; AIC (1)=100*log10(sigmaF(1)+2*(1+1);ZZ=inv(H1*H1);ZZ=inv(H1*H1);THETA=zeros(10,20);% THETA(2,:)=theta1;%*for n=2:1:10for i=1:1:100H2(i,:) = u(20+i-n) -1*z(20+i-n);endB=inv(H2*H2-H2*H1*ZZ*H1*H2);A=ZZ*H1*H2*B;th

16、eta2二B*H2*(z(21:120)-H1*theta1);theta1二theta1-A*H2*(z(21:120)-H1*theta1);theta1=theta1;theta2ZZ1=ZZ+A*H2*H1*ZZ -A;ZZ2=-A B;ZZ=ZZ1;ZZ2;H1=H1 H2;time(n-1)=n;sigmaF(n) = (z(21:120)-H1*theta1)*(z(21:120)-H1*theta1)/100; AIC (n-1)=100*log10(sigmaF(n)+2*(n+n);endplot(time,AIC,r-*)title(信息準則AIC值隨系統(tǒng)階次的變化)xlabel(系統(tǒng)階次)ylabel(信息準則AIC值)程序10clear%子子模型2的基于階次

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論