MATLAB: Does the Simulink model generate the error “Simulation is terminating because MATLAB has detected an output inconsistency”

checkconsistencys-funsfunctionsfunctionssimulink

I have a model created in Simulink 6.3 (R14SP3). This model contains S-Functions and custom made subsystem blocks. I can update my model successfully. However when I try to run the model, Simulink generates the following error message:
"Simulation is terminating because MATLAB has detected an output inconsistency".
The error message does not direct me towards any particular block in the model.

Best Answer

This error message is displayed when the option "Simulation->Configuration Parameters->Diagnostics->Solver Data Inconsistency" is selected as "error". This diagnostic tool should be mainly used for debugging models as it affects the performance (upto 40%).
One of the main uses of consistency checking is to make sure that S-functions adhere to the same rules as Simulink built-in blocks. You can use this check to validate your S-functions and to help you determine the cause of unexpected simulation results.
Another purpose of consistency checking is to ensure that blocks produce constant output when called with a given value of t (time). This is important for the stiff solvers (ode23s and ode15s) because, while calculating the Jacobian matrix, the block's output functions can be called many times at the same value of t.
When consistency checking is enabled, Simulink recomputes the appropriate values and compares them to the cached values. If the values are not the same, a consistency error occurs.
See Attached example which illustrates this behavior.