1、%广义最小方差自校正控制(直接算法)考虑如下系统: ()1.7()0.(2)(4)0.5()21ykykuuk式中 (k)为方差为 0.1 的白噪声。取 ,期望输出 yr(k)为幅值为 10 的111,(),()2PzRzQz方波信号。clear all;close all;a=1 -1.7 0.7;b=1 2;c=1 0.2;d=4;na=length(a)-1;nb=length(b)-1;nc=length(c)-1;nf=nb+d-1;ng=na-1;Pw=1;R=1;Q=2; %加权多项式np=length(Pw)-1;nr=length(R)-1;nq=length(Q)-1;L=
2、400;uk=zeros(d+nf,1);yk=zeros(d+ng,1);yek=zeros(nc,1);yrk=zeros(nc,1);xik=zeros(nc,1);%xiek=zeros(nc,1);yr=10*ones(L/4,1);-ones(L/4,1);ones(L/4,1);-ones(L/4+d,1);xi=sqrt(0.1)*randn(L,1);%RELS 初值设定thetaek=zeros(na+nb+d+nc,d);P=106*eye(na+nb+d+nc);for k=1:Ltime(k)=k;y(k)=-a(2:na+1)*yk(1:na)+b*uk(d:d+n
3、b)+c*xi(k);xik;%递推最小二乘法phie=yk(d:d+ng);uk(d:d+nf);-yek(1:nc);K=P*phie/(1+phie*P*phie);thetae(:,k)=thetaek(:,1)+K*(y(k)-phie*thetaek(:,1);P=(eye(na+nb+d+nc)-K*phie)*P;ye=phie*thetaek(:,d); %最优预测输出估计值% xie=y(k)-phie*thetae(:,k);%白噪声估计值%提取辨识参数ge=thetae(1:ng+1,k);fe=thetae(ng+2:ng+nf+2,k);ce=1 thetae(ng
4、+nf+3:ng+nf+2+nc,k);if abs(ce(2)0.9ce(2)=sign(ce(2)*0.9;endif fe(1)0yek(1)=ye;yrk(1)=yr(k);xik(1)=xi(k);endendfigure(1);subplot(2,1,1);plot(time,yr(1:L),r:,time,y);xlabel(k);ylabel(y_r(k),y(k);legend(y_r(k),y(k);axis(0 L -20 20);subplot(2,1,2);plot(time,u);xlabel(k);ylabel(u(k);axis(0 L -10 10);figure(2);subplot(211);plot(1:L,thetae(1:ng+1,:),1:L,thetae(ng+nf+3:ng+2+nf+nc,:);xlabel(k);ylabel(参数估计 g,c);legend(g_0,g_1,c_1);axis(0 L -3 4);subplot(212);plot(1:L,thetae(ng+2:ng+2+nf,:);xlabel(k);ylabel(参数估计 f);legend(f_0,f_1,f_2,f_3,f_4);axis(0 L 0 8);