This might be owing to initial conditions. In the GUI and in the COMPARE function, the fit is computed by estimating the initial conditions (by default) that maximize the fit to the data. In Simulink, you have to enter the appropriate initial conditions yourself based on your knowledge of the state of the system at the start of the simulation. To validate the estimation results in Simulink, you can do this:
- Split the estimation data into two parts such that the first part has as many samples as there are states in the model. See http://www.mathworks.com/help/toolbox/ident/ref/idnlarx.html
- Use the I/O variable values from the first part to specify initial conditions for simulation in the IDNLARX model block's dialog.
- Use the input signal from the second data part to perform the simulation in Simulink.
Your estimation results might appear to be better than they actually are owing to the effect of suitably chosen initial conditions (shown by the Model output plot). To check the true quality of the model, use COMPARE command in the MATLAB command window. Call COMPARE with zero initial conditions and see the fit values.