生成代码
生成代码和编译独立的库及可执行文件
App
函数
对象
主题
生成代码基础知识
- 代码生成工作流
从 MATLAB 代码生成 C/C++ 代码。 - 使用 MATLAB Coder 生成 C 代码
使用 MATLAB Coder 从 MATLAB 代码生成 C/C++ 代码。 - 通过命令行生成 C 代码
使用codegen
命令从 MATLAB 代码生成 C/C++ 代码。 - C++ 代码生成
了解 C++ 特定的代码生成注意事项。 - 设置 MATLAB Coder 工程
在 MATLAB Coder App 中设置工程。
在命令行和工程工作流之间切换
- Convert codegen Command to Equivalent MATLAB Coder Project
Use thecodegen
command with the-toproject
option. - Convert MATLAB Coder Project to MATLAB Script
Generate code at the command line by using project settings. - Share Build Configuration Settings
Export project settings to a code generation configuration object or import the settings into a project.
特定于数据的工作流
- Generate Code for Variable-Size Data
Generate code for data whose size might change at run time. - Generate Code for Global Data
Generate C/C++ code from MATLAB code that uses global data - Generate Code for Enumerations
Generate code from MATLAB code that uses enumerations.
扩展功能
- Generate Code for Multiple Entry-Point Functions
Generate C/C++ code for multiple entry-point functions. - Generate Code for Functions with Multiple Signatures
Generate code for multiple signatures. - Pass an Entry-Point Function Output as an Input
Simplify input type specification for multiple entry-point functions. - Generate Code That Uses Row-Major Array Layout
Generate C/C++ code with row elements stored contiguously in memory. - Generate Code That Uses N-Dimensional Indexing
Preserve array dimensions in generated code.
扩展的 C++ 功能
- Generate C++ Code with Class Interface
Generate C++ code that is packaged into a class. - Generate C++ Classes for MATLAB Classes
Generate a C++ class for a value class, handle class, or System object™ in your MATLAB code. - Use Dynamically Allocated C++ Arrays in Generated Function Interfaces
Understand and use dynamically allocated arrays from the generated C++ function interfaces. - Organize Generated C++ Code into Namespaces
Namespaces organize the generated code into logical parts and prevent name collisions.
代码外观
- Reserved Keywords
Certain words in your code, that are C/C++ keywords, might be renamed in the generated code.