User`s guide

Introduction
1-5
blocks with no states, x is an empty vector. In MEX-file S-functions, there are
two separate state vectors for the continuous and discrete states.
Simulation Stages and S-Function Routines
Simulink makes repeated calls during specific stages of simulation to each
block in the model, directing it to perform tasks such as computing its outputs,
updating its discrete states, or computing its derivatives. Additional calls are
made at the beginning and end of a simulation to perform initialization and
termination tasks.
The figure below illustrates how Simulink performs a simulation. First,
Simulink initializes the model; this includes initializing each block, including
S-functions. Then Simulink enters the simulation loop, where each pass
through the loop is referred to as a simulation step. During each simulation
step, Simulink executes your S-function block. This continues until the
simulation is complete: