MATLAB: The system identification models I’ve exported to the work space do not match the results from the toolbox. Why is this happening

system identification modelingSystem Identification Toolbox

I have been using the system identification toolbox to develop two models: a transfer function model and a state space model. Once I developed the toolbox, my goal was to process larger sets of data with a code. However, when I use my code to import the models and plot them, they are different than the results in the identification toolbox. Why is this occurring?
I have attached images of the results, with the code results on the left and the identification results on the right. I have also attached a zip file with the code and the system identification toolbox session.
As a note this has been tried on Matlab versions 2018a, 2017b, and 2017a.

Best Answer

What initial conditions are you using for simulation? Note that by default, the App estimates the initial conditions to maximize the fit to the output signal. See: https://www.mathworks.com/help/ident/ug/estimate-initial-conditions.html