Writing S-Functions    

Example of a Zero Crossing S-Function

The example S-function sfun_zc_sat demonstrates how to implement a Saturation block. This S-function is designed to work with either fixed- or variable-step solvers. When this S-function inherits a continuous sample time and a variable-step solver is being used, a zero-crossings algorithm is used to locate the exact points at which the saturation occurs.

matlabroot/simulink/src/sfun_zc_sat.c


  Example of a Variable-Step S-Function Example of a Time-Varying Continuous Transfer Function