Documentation

Function Definition

Define and call functions for code generation

Blocks

MATLAB Function Include MATLAB code in models that generate embeddable C code
MATLAB System Include System object in model

Functions

coder.extrinsic Declare extrinsic function or functions

Examples and How To

Specify Variable Numbers of Arguments

Use varargin and varargout for code generation.

Apply Operations to a Variable Number of Arguments

Use varargin and varargout in for-loops.

Implement Wrapper Functions

Use varargin and varargout to pass a variable number of inputs to another function.

Call Local Functions

Call local functions in MATLAB® code that is intended for code generation.

Call Supported Toolbox Functions

Call toolbox functions that are supported for code generation.

Extrinsic Functions

Declare a function as extrinsic when code generation does not support that function.

Force Code Generator to Use Run-Time Recursion

Rewrite your MATLAB code so that the code generator uses run-time recursion instead of compile-time recursion.

Concepts

Compilation Directive %#codegen

Indicate that a MATLAB function is intended for code generation.

Resolution of Function Calls for Code Generation

The code generator uses precedence rules to resolve function calls.

Resolution of File Types on Code Generation Path

The code generator uses precedence rules to resolve file types.

Variable Length Argument Lists for Code Generation

Adhere to code generation restrictions for varargin and varargout.

Supported Index Expressions

Index varargin and varargout in MATLAB code that is intended for code generation.

Code Generation for Anonymous Functions

Use anonymous functions in MATLAB code intended for code generation.

Code Generation for Recursive Functions

Use recursive functions in MATLAB code that is intended for code generation.

Troubleshooting

Compile-Time Recursion Limit Reached

Troubleshoot compile-time recursion limit error.

Output Variable Must Be Assigned Before Run-Time Recursive Call

Troubleshoot output variable assignment for run-time recursion.

Was this topic helpful?