Main Content

Code Generation for Custom Blocks

Use S-functions to define code generation behavior for custom blocks

An S-function is a computer language description of a Simulink® block written in MATLAB®, C, C++, or Fortran. You can develop an S-function to represent external code using a programming interface that interacts with the Simulink engine. Use this S-function with the code generator to produce code. Start with S-Functions and Code Generation.

For simpler alternative approaches for interfacing between generated and external code, see External Code Import.


Generated S-FunctionRepresent model or subsystem as generated S-function code


Write S-Functions

Legacy Code Tool

S-Function Builder Block