📄 sysideks.m
字号:
% 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -