Implement Algorithms Using C/C++ Code
Implement C/C++ code in Simulink® using the blocks you develop. You can use these methods to implement your code:
C Caller block — Integrates C code into Simulink by importing your C functions.
C Function block — Integrates and calls external C/C++ code from a Simulink model
S-Function — Uses special syntax called S-function API to communicate with the Simulink engine. They allow you to create continuous, discrete, and hybrid systems.
S-Function Builder block — Integrates C/C++ code by building an S-function from your code with the specifications you supply. The S-function builder also serves as a wrapper for the S-functions generated in your models.
Legacy Code Tool — Integrates C/C++ functions, such as lookup tables, and general functions and interfaces into Simulink models.
Use the C Caller block to call a C function to your model that has no states. To create an S-function without states, use Legacy Code Tool. To work with states and methods, use the C Function block, the S-function Builder or S-functions.
- Call C Code Using C Caller Block
Call simple external C code into Simulink by importing C functions
- Integrate External C/C++ Code Using C Function Blocks
Integrate and call external C/C++ code from a Simulink model
- Import Custom C/C++ Code Using the Simulink Code Importer
Create Simulink libraries from your custom C/C++ code with the Simulink Code Importer tool
- Implement C/C++ S-Functions
Extend capabilities of Simulink and bring your C/C++ code into Simulink
- Implement C/C++ Code Using S-Function Builder
Implement C/C++ code in your Simulink block by creating S-functions automatically