Code Generation

Guidelines for traceability and improving readability, external code integration


MATLAB FunctionInclude MATLAB code in models that generate embeddable C code


coder.allowpcodeControl code generation from protected MATLAB files
coder.cevalCall external C/C++ function
coder.cincludeInclude header file in generated code
coder.constFold expressions into constants in generated code
coder.cstructnameName structure in generated code
coder.extrinsicDeclare extrinsic function or functions
coder.inlineControl inlining in generated code
coder.loadLoad compile-time constants from MAT-file or ASCII file into caller workspace
coder.opaqueDeclare variable in generated code
coder.refPass argument by reference
coder.rrefPass argument by reference as read-only input
coder.screenerDetermine if function is suitable for code generation
coder.targetDetermine if code generation target is specified target
coder.unrollUnroll for-loop by making a copy of the loop body for each loop iteration
coder.wrefPass argument as write-only reference
coder.updateBuildInfoUpdate build information object RTW.BuildInfo


coder.ExternalDependencyInterface to external code
coder.BuildConfigBuild context during code generation

Examples and How To

Check Code Using the Code Generation Readiness Tool

Run the code generation readiness tool at the command line or from the current folder browser.

Use Traceability in MATLAB Function Blocks

Trace between source code and generated code in a MATLAB Function block.

Include MATLAB Code as Comments in Generated Code

Correlate generated code with source code.

Enhance Code Readability for MATLAB Function Blocks

Convert if-elseif-else code to switch-case statements.

Encapsulate Interface to an External C Library

Encapsulate the interface to an external C library with coder.ExternalDependency.

Update Build Information from MATLAB code

Control aspects of the build process after code generation but before compilation.


Code Generation Readiness Tool

Interpret code generation readiness tool report.

MATLAB Function Reports

Generate and interpret MATLAB Function reports.

Encapsulating the Interface to External Code

Encapsulate the interface to external code with coder.ExternalDependency.

Best Practices for Using coder.ExternalDependency

Use coder.ExternalDependency according to best practices.


Unknown Output Type for coder.ceval

Define the output type for external C/C++ function calls.

Was this topic helpful?