System ID function AR or ARMAX

4 ビュー (過去 30 日間)
Kin Cheong Sou
Kin Cheong Sou 2021 年 9 月 15 日
コメント済み: Kin Cheong Sou 2021 年 9 月 18 日
Hello,
I am trying to fit a sum of two exponentials with time-domain data using system identification toolbox functions ar or armax. It appears that the fitting quality is not good and it's not my expectation. I attach my simple code below. I wonder if I made any simple mistakes. Any idea would be welcome. Thanks!
% generate data: sum of 2 exp
N = 1000;
x = (0:(N-1))';
y0 = exp(-0.01*x)+0.8*exp(-0.1*x); % positive sum of two decaying exp
y = y0+0.01*max(y0)*randn(N,1); % add a bit of noise
% apply SYSID tools: ar or armax
n = 2;
yid = iddata(y,[],1);
%sys = ar(yid,n);
sys = armax(yid,[n 0]);
[yh, FIT, x0] = compare(yid,sys);
% show results
figure(1);
clf;
plot(x,y,x,yh.y,'LineWidth',4);
legend('data','SYSID');
disp('system poles');
disp(roots(sys.a));
Kin

採用された回答

Ivo Houtzager
Ivo Houtzager 2021 年 9 月 16 日
編集済み: Ivo Houtzager 2021 年 9 月 17 日
Define a step input, and fit OE model as this model structure fits your data the best. See updated code below.
% generate data: sum of 2 exp
d = 10; % input delay
p = 100; % start step
N = 1000;
x = [zeros(p+d,1); (1:(N-p-d))'];
y0 = exp(-0.01*x)+0.8*exp(-0.1*x); % positive sum of two decaying exp
y = y0+0.01*max(y0)*randn(N,1); % add a bit of noise
y = y - y0(1); % remove start value, as fit model around steady state zero
u = [zeros(p,1); ones(N-p,1)];
yid = iddata(y,u,1);
% apply SYSID tools: oe
n = 2;
[sys1,ic1] = oe(yid,[n n d]);
[yh1, FIT1] = compare(yid,sys1);
% apply SYSID tools: oe with initial estimate
init_sys = idpoly(zpk(0.8,[0.99 0.9],-y0(1),1)); % initial sys
init_sys.nk = d; % number of samples input delay
opt = oeOptions('InitialCondition','zero'); % initial state
[sys2,ic2] = oe(yid,init_sys,opt);
[yh2, FIT2] = compare(yid,sys2);
% show results
figure(1);
clf;
t = 0:N-1;
plot(t,u,t,y+y0(1),t,yh1.y+y0(1),t,yh2.y+y0(1),'LineWidth',4);
legend('input','data','SYSID1','SYSID2');
disp('system poles');
disp(roots(sys2.f));
  3 件のコメント
Ivo Houtzager
Ivo Houtzager 2021 年 9 月 17 日
編集済み: Ivo Houtzager 2021 年 9 月 17 日
Compared to the ARX model, the OE model optimization problem is non-linear. Thus the optimization is non-convex. Depending on the initial values, the non-linear optimization can get sometimes stuck in local optimum instead of going to global optimum. If you have an initial estimate or guess of parameters, you can give that as an option to the OE function to improve the convergence. The ARX model optimization problem is linear and does not have this issue as this optimization is convex, but will require high-order model to get a decent fit on your data.
For your second issue, you also have to pad the same number of samples of constant values to the output y as well.
I have updated the code in answer with example to remove the warning and to apply an initial estimate.
Kin Cheong Sou
Kin Cheong Sou 2021 年 9 月 18 日
Thank you again Ivo, for the explanation and the example. Now I understand this function much better.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulation and Prediction についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by