Main Content

Integrate C/C++ Code into Simulink

Integrate existing 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