MATLAB 类
MATLAB® 类的代码生成
您可以为 MATLAB 类生成代码,包括值类、句柄类和 System object。在生成的 C 代码中,MATLAB 类表示为结构体。如果您生成 C++ 代码,代码生成器的默认行为是为 MATLAB 类生成 C++ 类。在用于代码生成的 MATLAB 代码中使用类时,您必须了解一些特定的用法说明和限制。
类
coder.ClassType | Represent set of MATLAB classes acceptable for input specification |
主题
代码生成基础知识
- Generate Code for MATLAB Value Classes
Use a value class in MATLAB code intended for code generation. - 为 MATLAB 句柄类和 System object 生成代码
在用于代码生成的 MATLAB 代码中使用您的 System object™。 - Generate C++ Classes for MATLAB Classes
Generate a C++ class for a value class, handle class, or System object in your MATLAB code.
输入设定
- 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.
用法说明和限制
- 用于代码生成的 MATLAB 类定义
在用于进行代码生成的 MATLAB 代码中使用类。 - Classes That Support Code Generation
Generate code for MATLAB value and handle classes and user-defined System objects. - MATLAB 代码生成中的 System object
在 MATLAB 生成的代码中使用 System object 的特殊注意事项。 - Code Generation for Handle Class Destructors
Use a handle class destructor in MATLAB code intended for code generation.
疑难解答
Handle Object Limitations for Code Generation
Adhere to code generation restrictions for handle objects.
Troubleshoot issues with assignment of a property of a handle class.
Passing By Reference Not Supported for Some Properties
You cannot use certain properties with coder.ref
,
coder.rref
, or coder.wref
.
Resolve Error: Code Generator Failed to Produce C++ Destructor for MATLAB Class
Troubleshoot generation of standalone code for C++ destructor of a MATLAB class.
对 MATLAB 代码中对象数组的代码生成失败进行故障排除。