📄 example5_2.m
字号:
clear all;
U=idinput([15 1 30],'prbs',[0 1],[-1 1]);
subplot(1,2,1);stem(U);
title('系统输入序列');
hold on
i=100;R0=1;S=2.^25*eye(4);
Y=zeros(i,1);
theta0=[1.5;-0.7;1;0.5];
theta=[1;1;1;1];
V=idinput(i,'rgs',[0 1],[0 1]);%系统噪声
for m=3:i
X=[Y(m-1) Y(m-2) U(m-1) U(m-2)];
Y(m)=X*theta0+V(m);
F=S'*X';
Beta=R0+F'*F;
Arfa=1/(Beta+(R0*Beta)^0.5);
K=S*F/Beta;
theta(:,(m-1))=theta(:,(m-2))+K*(Y(m)-X*theta(:,(m-2)));
S=(eye(4)-Arfa*Beta*K*X)*S/R0^0.5;
end
result=[(-theta(1:2,(i-1)));theta(3:4,(i-1))];%进行辨识模型并输出系数a1,a2,b1,b2结果
subplot(1,2,2);stem(Y);title('系统输出Y');%绘制辨识参数
figure;
plot(1:(i-1),-theta(1,:),'--',1:(i-1),-theta(2,:),'-.',1:(i-1),theta(3,:),':',1:(i-1),theta(4,:),'-');
A=plot(1:(i-1),-theta(1,:),'--',1:(i-1),-theta(2,:),'-.',1:(i-1),theta(3,:),':',1:(i-1),theta(4,:),'-');
legend(A,'a1','a2','b1','b2');
title('参数辨识');hold on
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -