Main Content

External Code Integration

Choose and apply integration paths and methods

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, exporting generated code into an existing external code base, or you can do both. 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.

You can export generated code as a plug-in function for use in an external development environment. When you export generated code, you intend to interface that code manually with a scheduling mechanism in your application run-time environment.

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


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


Getting Started

Import External Code Into Generated Code

Control Data and Code Interfaces

Control Generated Code to Match Other Integration Requirements