Update a block's states
Instance of Simulink.MSFcnRunTimeBlock class 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 IsSampleHit to 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 IsSampleHit property of the run-time object's InputPort or OutputPort to determine if the port produces outputs or accepts inputs at the current simulation time step.