本页对应的英文页面已更新,但尚未翻译。 若要查看最新内容,请点击此处访问英文页面。

函数定义

为代码生成定义和调用函数

模块

MATLAB FunctionMATLAB 代码包含在生成可嵌入式 C 代码的模型中
MATLAB System在模型中包含 System object

函数

coder.extrinsic声明外部函数
coder.ignoreSizePrevent code generator from creating function specializations for constant-size expressions
coder.ignoreConstPrevent use of constant value of expression for function specializations
coder.unrollUnroll for-loop by making a copy of the loop body for each loop iteration

主题

编译指令 %#codegen

指示 MATLAB® 函数用于代码生成。

Code Generation for Variable Length Argument Lists

Generate code for varargin and varargout.

递归函数的代码生成

在用于代码生成的 MATLAB 代码中使用递归函数。

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.

Code Generation for Anonymous Functions

Use anonymous functions in MATLAB code intended for code generation.

Code Generation for Nested Functions

Use nested functions in MATLAB code 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.

外部函数

将代码生成不支持的函数声明为外部函数。

疑难解答

Nonconstant Index into varargin or varargout in a for-Loop

Force loop unrolling when the code generator cannot determine the value of the index into varargin or varargout.

Avoid Duplicate Functions in Generated Code

Reduce the occurrence of duplicate functions in the generated code.

Output Variable Must Be Assigned Before Run-Time Recursive Call

Troubleshoot output variable assignment for run-time recursion.

Compile-Time Recursion Limit Reached

Troubleshoot compile-time recursion limit error.