Why is the estimated response from function 'n4sid' different than that from the 'System Identification' app in R2022b?

2 views (last 30 days)
I am using the System Identification Toolbox in MATLAB release R2022b to estimate a model for my data. I am using the function 'n4sid' as follows:
>> sysest = n4sid( measuredData , 2);
where 'measuredData' is a data object created by function 'iddata', and contains no input.
When I compare the response of the estimated model 'sysest' with the measured data using function 'compare', I get the following plot:
>> compare(measuredData,sysest);
However, when I use the 'System Identification' app and load it with the same data object 'measuredData', I get the following graph as 'Model output':
The app says it is using 'n4sid' in the model estimation, but the app's result does not match with the result of my own call to 'n4sid'.
Why am I getting different results?​​​

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Mar 2023
The 'System Identification' app uses 'n4sid' internally and should give equivalent results to the MATLAB script, when called with the same inputs and options. A nice feature of the app is that if you right-click on the estimated model, it will show the code it ran. For example, see the model 'ss1' created from the data 'measuredData' in the image below.
The reason why those two plots are different is because they are plotting different types of response. The plot created by the MATLAB script uses 'compare', which estimates the dynamic response of the estimated system from an initial position into the future. On the other hand, the app uses the function 'predict'. This function computes the output of the model only 5 steps ahead, by default.
Function 'compare' is documented here: https://www.mathworks.com/help/releases/R2022b/ident/ref/compare.html
Function 'predict' is documented here: https://www.mathworks.com/help/releases/R2022b/ident/ref/predict.html

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!