1、grid on;title(一阶系统模型的验证);xlabel(仿真时间ylabel(系统的响应值set(gca,xtick,0:10);ytick1:20);所得的仿真图形如下,实际系统加入测试信号后,从workspace中可发现系统的响应值为h=;验证是的对应仿真值为h=;其误差大小为:()/*100%=%;同理,当仿真时间为时,h=;h=;误差大小为: ()/*100%=%;所以经过验证个,可以确定该辨识结果可以反应该系统的传递函数。实验二相关分析法aa=5;NNPP=15;ts=2;RR=ones(15)+eye(15);UU=UY(31:45,1);UY(30:44,1)UY(29:
2、43,1)UY(28:42,1)UY(27:41,1) UY(26:40,1)UY(25:39,1)UY(24:38,1)UY(23:37,1)UY(22:36,1) UY(21:35,1)UY(20:34,1)UY(19:33,1)UY(18:32,1)UY(17:31,1);YY=UY(16:30,2);GG=(RR*UU*YY+/aa*aa*(NNPP+1)*ts; plot(0:2:29,GG)hold onstem(0:29,GG,filled)(1) 最小二乘二阶一次完成算法HL=;N=15;m序列的周期n=2;系统的阶次for k=16:15+N a=-UY(n+k-1:-1:k
3、,2) UY(n+k-1:k,1) HL=HL;a;end ZL=UY(n+16:n+N+15,2);c1=HL*HL; c2=inv(c1); c3=HL*ZL; c=c2*c3;a1=c(1), a2=c(2), b1=c(3), b2=c(4);求得:a1=;a2=;a3=;a4=;(2)最小二乘三阶的一次完成算法n=3;a1=c(1), a2=c(2), a3=c(3), b1=c(4);b2=c(5);b3=c(6);求得相关系数为: a1=; a2=; a32=; b1=; b2=; b3=;(3)最小二乘法二阶一般递推算法%RLS递推最小z=UY(:,2);u=UY(:,1);c
4、0= ;直接给出参数的初始值p0=104*eye(4,4); 直接给出初始状态P0,已给很大的单位实矩阵c=c0,zeros(4,198); 存储各部迭代后的参数值 k=3:200; 开始迭代 h1=-z(k-1),-z(k-2),u(k-1),u(k-2) x=h1*p0*h1+1*lamt; x1=inv(x); k1=p0*h1*x1; d1=z(k)-h1*c0; c1=c0+k1*d1;p1=1/lamt*(eye(4)-k1*h1)*p0; c(:,k)=c1; c0=c1;更新C0 p0=p1;%更新C1a1=c(1,: a2=c(2,: b1=c(3,: b2=c(4,:i=1
5、:plot(i,a1,r,i,a2,b,i,b1,f,i,b2,k) 递推最小二乘法参数辨识 (3)最小二乘法三阶递推算法c0= ,p0=104*eye(6,6);c=c0,zeros(6,198);for k=4: h1=-z(k-1),-z(k-2),-z(k-3),u(k-1),u(k-2),u(k-3)p1=1/lamt*(eye(6)-k1*h1,k-2)=c1;% a3=c(3,: b1=c(4,: b2=c(5,:b3=c(6,:199;,i,a3,blackgy,i,b3,递推最小二乘参数辨识(2)加阶跃扰动后的参数辨识带遗忘因子的最小二乘法clc;lamt=;c0= for
6、k=3:200d1=z(k)-h1 p1=1/lamt*(eye(4)-k1*h1,k-1)=c1; p0=p1;) ;lamt=的遗忘最小二乘法 grid onlamt=1;k1=p0*h1*x1;%C1figure(2);最小二乘法(3)搭建的对象为广义最小二乘法M=UY(1:800,1);v=randn(1,800);e=;e(1)=v(1);e(2)=v(2);for i=3:800e(i)=0*e(i-1)+0*e(i-2)+v(i);z=UY(1:800,2);zf=;zf(1)=-1;zf(2)=0;zf(i)=z(i)-0*z(i-1)-0*z(i-2);uf=;uf(1)=M
7、(1);uf(2)=M(2);uf(i)=M(i)-0*M(i-1)-0*M(i-2);P=100*eye(4);Theta=zeros(4,800);Theta(:,2)=3;3;3;K=10;10;10;PE=10*eye(2);ThetaE=zeros(2,800);ThetaE(:,2)=;KE=10;h=-zf(i-1);-zf(i-2);uf(i-1);uf(i-2);K=P*h*inv(h*P*h+1);,i)=Theta(:,i-1)+K*(z(i)-h*Theta(:,i-1);P=(eye(4)-K*h)*P;he=-e(i-1);-e(i-2);KE=PE*he*inv(
8、1+he*PE*he);,i)=ThetaE(:,i-1)+KE*(e(i)-he*ThetaE(:PE=(eye(2)-KE*he)*PE;800;figure(1);plot(i,Theta(1,:),i,Theta(2,:),i,Theta(3,:),i,Theta(4,:) figure(3);plot(i,ThetaE(1,:),i,ThetaE(2,:);v=randn(800);P=100*eye(6);Theta=zeros(6,799);,1)=3;h=-z(i-1);-z(i-2);M(i-1);M(i-2);v(i-1);v(i-2);,i-1)=Theta(:,i-2)+K*(z(i)-h,i-2);P=(eye(6)-K*h799;figure(1),i,Theta(5,:),i,Theta(6,:增广最小二乘实验总结(1) 通过本次试验对系统辨识的概念和作用有了进一步的理解。(2) 通过本次试验了解到系统辨识加入的阶跃信号是在系统已经稳定的基础上加入的,所有相关量的计算都应将系统稳定时的状态量减去进行计算。(3)
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1