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

9 vues (au cours des 30 derniers jours)
Caroline BADER
Caroline BADER le 23 Juin 2020
Commenté : Star Strider le 23 Juin 2020
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!

Réponse acceptée

Star Strider
Star Strider le 23 Juin 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 commentaires
Caroline BADER
Caroline BADER le 23 Juin 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);
Star Strider
Star Strider le 23 Juin 2020
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time and Frequency Domain Analysis dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by