📄 bdu_regularizedls_main.asv
字号:
% 用多步线性化方法求解一个非线性最小二乘问题
% (Regularized least squares problem with bounded data uncertainty)
% problem formulation
% standard least squares problem:
% J1=min||Ax-b||
% solution: x=inv(A'*A)*A'*b
% Regularized least squares problem:
% J2=min[||Ax-b||^2+p||x||^2]
% solution: x=inv(A'*A+p*I)*A'*b;
% BDU RLS:
% J3=min max[||[A+e_A]*x-[b+e_b]||^2+p||x||^2]
% where e_A,e_b:the uncertainty,||e_A||<=La,||e_b||<=Lb
% La,Lb: the upper bound of the uncertainty of A and b
% J3=>J4=min[[||Ax-b||+La*||x||+Lb]^2+p||x||^2]
% solution:x=inv(A'*A+r*I)*A'*b
% r=La*||Ax-b||/||x||+p*||Ax-b||/(||Ax-b||+La*||x||+Lb)
clear all;
clc;
dataLen=30;
%===== model and data ====:
%Ao*y(t)=Co*e(t):
Ao=[1 -1.5 0.687];
% Ao=[1 0.4 -0.1];
Co=[1];
MOP=[length(Ao)-1 length(Co)-1];
sys = idpoly(Ao,[],Co);
e = idinput(dataLen,'rgs');
y = sim(sys,e); % y is a vector here
%==========================.
[A b]=idenMatrix(y,MOP);
x0=eps*ones(sum(MOP),1);
La=0;Lb=0;
[Xs r]=multiLinearBDURLS(x0,A,La,b,Lb);
tend=length(Xs);
figure(1);
subplot(311);plot(1:tend,Ao(2)*ones(tend,1),'k--',1:tend,Xs(:,2),'r')
subplot(312);plot(1:tend,Ao(2)*ones(tend,1),'k--',1:tend,Xs(:,2),'r')
subplot(313);plot(1:tend,Ao(2)*ones(tend,1),'k--',1:tend,Xs(:,2),'r')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -