This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Integrate Legacy Code

Integrate existing C or C++ functions, such as device drivers or external simulation code

You can integrate existing C (or C++) functions, such as device drivers, lookup tables, and general functions and interfaces, into Simulink® models by using the Legacy Code Tool. Use the Legacy Code Tool to specify the name of the S-function, files, and path required for the compilation, and options for the generated S-function.

Use the legacy_code function to generate an S-function, compile and link the generated S-function, and create a mask for calling the generated S-function.

Before you can use legacy_code, ensure that a C compiler is set up for your MATLAB® installation.


legacy_codeUse Legacy Code Tool


Integrate C Functions Using Legacy Code Tool

Use the Legacy Code Tool to generate S-functions automatically from existing C code.

S-Functions Incorporate Legacy C Code

Incorporate legacy C code using a handwritten C MEX S-function, the S-Function Builder, and the Legacy Code Tool.

Integrate C Code Using the MATLAB Function Block

Use MATLAB Function block to call external C code and how to control enumeration and bus typedefs.

Featured Examples