sysideks.m

来自「基于加权最小二乘辨识的自适应极点配置算法」· M 代码 · 共 62 行

M
62
字号
% sysideks
% without exponential forgetting
% HR 5. februar 1999


% parameters for simulation
Tstop=200; h=0.5; Nstop=Tstop/h;
y   =zeros(1,Nstop);
u   =zeros(1,Nstop);
yr  =zeros(1,Nstop);
plt =zeros(4,Nstop);
time=h*(1:Nstop);

% parameters for simulation
T0=0.5; Thau=2; K0=1; a1=-exp(-h/Thau); a2=0; b1=0; b2=1+a1;

% parameters for sysid
t0=20; G=zeros(4,1); R=zeros(4,4); theta=zeros(4,1);

for t=3:Nstop
   % supervision
   if (t==round(100/h)) K0=2; end
   if (sin(2*pi/20*time(t))>0) Uman=1;
   else                        Uman=0; end

   % system simulation
   y(t) = -a1*y(t-1)-a2*y(t-2)+K0*(b1*u(t-1)+b2*u(t-2));

   % control
   u(t)=Uman;

   % parameter update
   my=1/t;
   phi=[-y(t-1) -y(t-2) u(t-1) u(t-2)]';
   G=(1-my)*G+my*phi*y(t);
   R=(1-my)*R+my*phi*phi';
   if (abs(det(R))> 0.0) theta=R\G; end
   plt(1,t)=theta(1);
   plt(2,t)=theta(2);
   plt(3,t)=theta(3);
   plt(4,t)=theta(4);

end

plot(time,u,time,y)
title('u & y')
xlabel('time [s]')
pause
close

plot(time,plt(1,:),time,plt(2,:))
title('a1 & a2')
xlabel('time [s]')
pause
close

plot(time,plt(3,:),time,plt(4,:))
title('a1 & a2')
xlabel('time [s]')
pause
close

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?