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

조회 수: 9 (최근 30일)
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);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time 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