从输入和输出数据中,我必须用最小二乘法识别 ARX 模型
y(n) = -a1 y(n-1) -....- aN y(nN) + b1 x(n-1)+...+bM x(nM)
必须是稳定的(它的所有极点都在单位圆内)并且同时参数
a1,...,aN, b1,...,bM
必须满足一些线性等式约束。例如我需要一个等于 1 的静态增益,这意味着
-a1-a2...-aN+b1+b2...+bM =1
在矩阵形式中,我可以将约束写为:
Theta = [a1 a2 ... aN b1 b2 ... bM]';
Aeq = [-ones(1,N) 个(1,M)];
beq = 1;
Aeq*theta=beq;
使用下面的 Matlab 函数,我可以使用 Matlab 函数 'ARX' 设置参数arx_stable
来识别稳定(但没有等式线性约束)ARX
'Focus' ='stability'
使用以下函数arx_constr
,我可以识别ARX
具有线性等式约束 Aeq beq (但没有稳定性)
我怎样才能既稳定又尊重约束???谢谢,
西蒙娜
function theta = arx_stable(N,M,t,input_data,output_data)
% input_data and output_data are column vectors
% t is the time vector
% data structure generation:
Ts = t(2)-t(1); % it is the sampling time
data = iddata(output_data,input_data,Ts);
n_k=0; % it is the Input-output delay
ARX_model = arx(data,[N M n_k] , 'Focus','stability');
% 'Focus','stability' in this way the identified ARX is stable
a=ARX_model.a;
a=a(2:end); % I remove the first a0=1
b=ARX_model.b;
theta=[a b];
end
function theta = arx_constr(N,M,t,input_data,output_data,Aeq,beq)
% input_data and ouput_data are row vectors
% t is the time vector
% X and y construction:
n_order=max([N M]);
X=[]; % X is the regression matrix
for nn = n_order+1:length(input_data)
X(nn,:)=[-output_data((nn-1):-1:(nn-N)) input_data((nn-1):-1:(nn-M))];
end
X=X((n_order+1):end,:); % it cancels the first n_order rows that are full of zeros
y=output_data(n_order+1:end)' ; % y is a column vector
options_lsqlin=optimset('Algorithm','active-set','LargeScale','off');
% this set is necessary to use equality constraints
theta=lsqlin(X,y,[],[],Aeq,beq,[],[],[],options_lsqlin);
end