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. You can import code by calling an external function, by using C Function blocks, C Caller blocks, or S-functions. To place external code at specific locations in generated code, you can include Custom Code blocks in a model or use model configuration parameters in the Custom pane. 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

Workflow Overview

Import External Code Into Generated Code