资源描述:
《广义最小方差自校正控制(直接算法)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、%广义最小方差自校正控制(直接算法)考虑如下系统:式中x(k)为方差为0.1的白噪声。取,期望输出yr(k)为幅值为10的方波信号。clearall;closeall;a=[1-1.70.7];b=[12];c=[10.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=400;uk=zeros(d+nf,1);yk=zeros(d+ng,1);yek=zeros(
2、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=10^6*eye(na+nb+d+nc);fork=1:Ltime(k)=k;y(k)=-a(2:na+1)*yk(1:na)+b*uk(d:d+nb)+c*[xi(k);xik];%递推最小二乘法phie=[yk(d:d+ng);
3、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=[1thetae(ng+nf+3:ng+nf+2+nc,k)'];ifabs
4、(ce(2))>0.9ce(2)=sign(ce(2))*0.9;endiffe(1)<0.1fe(1)=0.1;end%[e,f,g]=singlediophantine(ae,be,ce,d);CQ=conv(ce,Q);FP=conv(fe,Pw);CR=conv(ce,R);GP=conv(ge,Pw);u1=-Q(1)*CQ(2:nc+nq+1)*uk(1:nc+nq)/fe(1)-FP(2:np+nf+1)*uk(1:np+nf);u2=CR*[yr(k+d:-1:k+d-min(d,nr+nc));yrk(1:nr+nc-d)];u(k)=(u1+u2-GP*[y(k)
5、;yk(1:np+ng)])/(Q(1)*Q(1)/fe(1)+fe(1));%更新数据fori=d:-1:2thetaek(:,i)=thetaek(:,i-1);endthetaek(:,1)=thetae(:,k);fori=d+nf:-1:2uk(i)=uk(i-1);enduk(1)=u(k);fori=d+ng:-1:2yk(i)=yk(i-1);endyk(1)=y(k);fori=nc:-1:2yek(i)=yek(i-1);yrk(i)=yrk(i-1);xik(i)=xik(i-1);endifnc>0yek(1)=ye;yrk(1)=yr(k);xik(1)=x
6、i(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([0L-2020]);subplot(2,1,2);plot(time,u);xlabel('k');ylabel('u(k)');axis([0L-1010]);figure(2);subplot(211);plot([1:L],thetae(1:ng+1,:),[1:L],thetae(ng+nf+3:ng+2+nf+nc,
7、:));xlabel('k');ylabel('参数估计g,c');legend('g_0','g_1','c_1');axis([0L-34]);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([0L08]);