Represent external code using an API that interacts with the Simulink® engine. Using S-functions you can integrate existing C (or C++) functions, such as device drivers, lookup tables, and general functions and interface.
Customize generated code to improve performance. Using the Target Language Compiler, you can write a target for your C MEX S-function to inline the S-function. Inlining an S-function incorporates the S-function block's code into the generated code for the model, reducing overhead.