Writing S-Functions    

Example - 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 - Variable Step S-Function Example - Time Varying Continuous Transfer Function