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

9 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Star Strider
Star Strider am 23 Jun. 2020
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 Kommentare
Caroline BADER
Caroline BADER am 23 Jun. 2020
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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Time and Frequency Domain Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by