Why is there a difference between "compare" function and "lsim" function ?

9 ビュー (過去 30 日間)
Caroline BADER
Caroline BADER 2020 年 6 月 23 日
コメント済み: Star Strider 2020 年 6 月 23 日
Hello everyone,
I am currently working on the identification of the transfer function of my model and I have troubles understanding the systemIdentification Toolbox, let me explain.
The "model output" proposed by the toolbox is what I want. I export the transfer function and use lsim to plot it on my command window but I get something else.
I assume that the function compare is what the toolbox uses to plot the function (because the plot is very similar and there is a goodness of fit coefficient) but I don't know why this type of plotting is different from the lsim type.
I'm using the same input/output data, the same transfer function, the same sample time and yet both plots are different. Here's a picture to show you :
and the code used to plot the figure:
test1 = iddata(Y5,U5,0.01); %iddata(output,input,Ts)
sys5 = tfest(test1,4,0); %tfest(model,pole,zero)
test2 = lsim(sys5,U5,T5);
figure
compare(test1,sys5)
hold on
plot(T5,test2,'r')
title({'Difference between "compare" function and "lsim" function' 'TF : 4 poles 0 zero'})
legend('Output measured','"Compare" function','"lsim" function')
Does someone know how both functions work ? Or why they are different?
It would help me a lot, thank you in advance!

採用された回答

Star Strider
Star Strider 2020 年 6 月 23 日
Reading the documentation of compare and lsim, the only significant difference is that compare automatically estimates the initial states (see x0 in Output Arguments) while lsim does not, requiring that they be stated specifically, although findstates can be used to estimate them.
  2 件のコメント
Caroline BADER
Caroline BADER 2020 年 6 月 23 日
Thank you a lot !!! I added initial conditions in lsim and it totally worked !
x0 = findstates(sys5,test1,Inf) ;
test2_x0 = lsim(sys5,U5,T5,x0);
Star Strider
Star Strider 2020 年 6 月 23 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime and Frequency Domain Analysis についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by