Writing S-Functions | ![]() ![]() |
What Is an S-Function?
An S-function is a computer language description of a Simulink block. S-functions can be written in MATLAB, C, C++, Ada, or Fortran. C, C++, Ada, and Fortran S-functions are compiled as MEX-files using the mex
utility described in the Application Program Interface Guide. As with other MEX-files, they are dynamically linked into MATLAB when needed.
S-functions use a special calling syntax that enables you to interact with Simulink's equation solvers. This interaction is very similar to the interaction that takes place between the solvers and built-in Simulink blocks. The form of an S-function is very general and can accommodate continuous, discrete, and hybrid systems.
![]() | Overview of S-Functions | Using S-Functions in Models | ![]() |