Update a block's states
Simulink.MSFcnRunTimeBlockclass representing the Level-2 MATLAB S-Function block.
The Simulink® engine invokes this optional method at each major simulation time step. The method should compute the S-function's states at the current time step and store the states in the S-function's state vector. The method can also perform any other tasks that the S-function needs to perform at each major time step.
Use this code if your S-function has one or more discrete states or does not have direct feedthrough.
The reason for this is that most S-functions that do not have discrete states but do have direct feedthrough do not have update functions. Therefore, the engine is able to eliminate the need for the extra call in these circumstances.
In Level-2 MATLAB S-functions, use the run-time object method
determine if the current simulation time is one at which a task handled
by this block is active. For port-based sample times, use the
of the run-time object's
determine if the port produces outputs or accepts inputs at the current
simulation time step.
For an example that uses this function to update discrete states,