MATLAB: What are minor steps in Simulink and is it possible to obtain them from within an S-function

exportintegrationinvalidlogmajorminors-functionsfunctionsimulinksteptimevalid

I would like to know what are minor steps in Simulink solvers. Also, I was not able to find a way in the Simulink documentation how to export minor integration steps in Simulink using an S-Function.

Best Answer

During the integration stage, the solver obtains the derivatives from the system and uses it to compute a new state vector for the next time step. This entire process is called the integration phase or minor time step.
The following documentation has a graphical representation of the calling sequence of an S-function which should help to make this more clear:
How S-Functions Work:
Please type the following in MATLAB (R14SP2):
web([docroot,'/toolbox/simulink/sfg/sfun_intro6.html'])
There is no macro for finding the minor time steps inside an S-function. For the Simulink solver to work properly, it is important that functions like mdlOutput and mdlDeritative give the same result for the same inputs and states. Trying to manipulate the minor steps violates this expectation. The diagnostic "Solver data inconsistency" covers some of this. Please refer to the documentation at:
Further, the next attempt one would try at this point would be to specify properties like the solver Jacobian and the mass matrix. Unfortunately this is not possible in Simulink. If the minor step putputs are required to solve Differential Algebraic Equations (DAE), Simscape is the recommend approach.
However, it is possible to log the minor step data to workspace for debugging. The Related Solution below (Is it possible to log data from the minor time steps in a Simulink model into the MATLAB workspace?) presents an example of how to log minor time steps into the MATLAB workspace.