Main Content

External Code Import

Choose and apply options for importing external MATLAB®, C, or C++ code

The code generator includes a variety of approaches for integrating legacy or custom code with generated code. Legacy code is existing handwritten code or code for environments that you integrate with code that the code generator produces. Custom code is legacy code or other user-specified lines of code that you include in the code generator build process. Collectively, legacy and custom code are called external code.

You integrate external code by importing existing external code into code produced by the code generator. For example, you can import code by calling an external function, by using the Legacy Code Tool, or place external code at specific locations in generated code by including Custom Code blocks in a model. When you import external code, the resulting generated code interfaces with generated scheduling code.

For guidance on choosing an approach based on your application requirements, see Choose an External Code Integration Workflow.

Blocks

expand all

Model HeaderSpecify external header code
Model SourceSpecify external source code
System DerivativesSpecify external system derivative code
System DisableSpecify external system disable code
System EnableSpecify external system enable code
System InitializeSpecify external system initialization code
System OutputsSpecify external system outputs code
System StartSpecify external system startup code
System TerminateSpecify external system termination code
System UpdateSpecify external system update code

Topics

Getting Started

Import External Code Into Generated Code