Main Content

代码生成指南:生成可部署的 C/C++ 代码

可以使用 MATLAB® Coder™ 为 MATLAB 代码生成 C/C++ 代码。您可以:

  • 生成独立 C/C++ 代码以作为源代码、静态库或动态库在工程中使用。

  • 生成 MEX 代码以加速计算密集型操作。

按照本指南中的任务进行操作,学习独立代码生成及其部署。

  1. 准备您的 MATLAB 代码以进行代码生成。

  2. 从您的 MATLAB 代码生成 C/C++ 代码。

  3. 测试生成的 C/C++ 代码。

  4. 将生成的代码部署到现有工程中。

要确定完成代码生成过程所需的任务,请使用此工作流程图。

快速向导工作流

This image highlights the steps involved in the code generation. It starts with identifying the function to generate code for. In the second step, prepare the MATLAB code for code generation. In the third step, specify input types and check for run-time issues. Follow this by configuring build settings and generating code. Test the generated code to see if it performs as expected. If not, make changes in the code or in the build configurations. Deploy the required code as the last step.

要开始本教程,请参阅准备 MATLAB 代码以进行代码生成

相关主题