Real-Time Workshop    

Sample Time Propagation in Generated S-Functions

Note that sample time propagation for the S-function code format is slightly different from the other code formats. A generated S-Function block will inherit its sample time from the model in which it is placed if (and only if) no blocks in the original model specify their sample times.

Choice of Solver Type

If the model containing the subsystem from which you generate an S-function uses a variable step solver, the generated S-function will contain zero crossing functions. Therefore, the generated S-function will work properly in models with either variable step or fixed step solvers.

On the other hand, if the model containing the subsystem from which you generate an S-function uses a fixed step solver, the generated S-function contains no zero crossing functions. In this case, you can use the generated S-function only within models that use fixed-step solvers.


  Creating an S-Function Block from a Subsystem Tunable Parameters in Generated S-Functions