输入设定
指定 MATLAB® 函数输入变量的属性以启用代码生成
代码生成需要设定输入类型和属性。代码生成器使用输入信息来确定在后续变量定义中应如何定义变量的类型、大小及其他属性。通过 App、命令行或使用代码生成器生成类型编辑器,使用 coder.typeof
、coder.varsize
和 assert
等函数在函数代码的外部或内部来执行输入设定。对于某些输入类型,如元胞、类和全局变量,输入设定可能涉及其他考虑事项。
函数
coder.getArgTypes | Determine types of function input arguments by executing test file |
coder.newtype | Create coder.Type object to represent type of an entry-point
function input |
coder.resize | 调整 coder.Type 对象的大小 |
coder.typeof | Create coder.Type object to represent the type
of an entry-point function input |
coder.varsize | 声明可变大小数据 |
coderTypeEditor | Launch the Coder Type Editor dialog (自 R2020a 起) |
类
coder.ArrayType | Represent set of MATLAB arrays acceptable for input specification |
coder.CellType | Represent set of MATLAB cell arrays |
coder.ClassType | Represent set of MATLAB classes acceptable for input specification |
coder.Constant | Specification of constant value for code generation |
coder.EnumType | Represent set of MATLAB enumerations acceptable for input specification |
coder.FiType | Represent set of MATLAB fixed-point arrays acceptable for input specification |
coder.PrimitiveType | Represent set of logical, numeric, or character arrays acceptable for input specification |
coder.StructType | Represent set of MATLAB structure arrays acceptable for input specification |
coder.StringType | Represent set of MATLAB strings acceptable for input specification (自 R2022b 起) |
coder.Type | Represent set of MATLAB values acceptable for input specification |
对象
coder.OutputType | Output type from an entry-point function to specify as an input type |
主题
输入设定基础知识
- Specify Properties of Entry-Point Function Inputs
Specify input properties so that the code generator can determine the properties of all variables. - 使用 App 自动定义输入类型
提供使用具有代表性数据来调用入口函数的测试。 - Specify Number of Entry-Point Function Input or Output Arguments to Generate
Control the number of arguments in generated entry-point functions. - Define Input Properties Using assert Statements in MATLAB Code
Define the properties of entry-point function inputs with theassert
function. - Create and Edit Input Types by Using the Coder Type Editor
Define and editcoder.Type
objects interactively. - Pass an Entry-Point Function Output as an Input
Simplify input type specification for multiple entry-point functions. - Edit and Represent Coder Type Objects and Properties
Command line representation of coder type objects.
MATLAB Coder
- Define Input Parameter by Example by Using the App
Specify properties of an input parameter by providing an example value. - Define or Edit Input Parameter Type by Using the App
Specify the class, size, and complexity of an input parameter. - Make Dimensions Variable-Size When They Meet Size Threshold
Specify and apply rules for making dimensions variable-size. - 撤消和重做对 App 中类型定义的更改
恢复和还原对输入或全局变量定义的更改。
元胞数组
- 定义元胞数组输入
选择指定元胞数组输入的方式。 - Specify Cell Array Inputs at the Command Line
Provide an example cell array, define a cell array type, or specify a cell array constant input. - Specify Global Cell Arrays at the Command Line
Specify global cell array inputs with the-globals
option.
值类
- Specify Objects as Inputs at the Command Line
Specify that an entry-point input is an object of a value class by using thecodegen
-args
option. - Specify Objects as Inputs in the MATLAB Coder App
Define the type of a value class input from a test file or an example input.
全局数据
- Generate Code for Global Data
Generate C/C++ code from MATLAB code that uses global data - Add Global Variables by Using the App
Define global variables. - 使用 App 指定全局变量类型和初始值
指定 MATLAB 代码使用的全局变量的类型和初始值。
常量数据
- Constant Input Checking in MEX Functions
Control whether a MEX function checks the value of a constant input argument. - Define Constant Input Parameters Using the App
Specify that an input parameter is a constant.
字符串标量
- 定义字符串标量输入
选择指定字符串标量输入的方式。