Integrate C/C++ Code into Simulink
Choose the appropriate C/C++ code integration tool for your model:
If you have simple C/C++ functions that you want to integrate and its Simulink implementation does not require advanced block customizations, use C/C++ code importers.
If you have C/C++ code that you want to integrate, use the C MEX S-function when its Simulink implementation requires:
Continuous or discrete states
Multirate ports
Variable sized input and output ports
Zero-crossing detection
Complete interaction with Simulink engine
This workflow might require manually creating a Target Language Compiler (TLC) file for code generation.
If you have simple C/C++ code that you want to integrate and want to generate code without manually writing a TLC file, use S-Function Builder.
For a detailed guide to selecting an appropriate C/C++ code integration tool, see Choose Tools to Integrate Existing Components and MATLAB, C/C++, or Python Code into Simulink.
Categories
- Integrate C/C++ Code Using Code Importers
Use Simulink Code Importer, C Caller block, or C Function block to import your C code
- Integrate C/C++ Code Using C MEX S-Functions
Use C MEX S-Function to integrate existing C/C++ code
- Integrate C/C++ Code Using S-Function Builder
Integrate your C/C++ code into Simulink models by creating S-functions automatically
- Integrate C/C++ Code Using Legacy Code Tool
Integrate existing C or C++ functions, such as device drivers or external simulation code