Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

MATLAB 代码分析

识别并修复 MATLAB® 代码中阻止生成 C/C++ 代码的问题

要从 MATLAB 代码成功生成 C/C++ 代码,需要遵循代码生成规则和限制。例如,您的 MATLAB 代码必须仅使用支持代码生成的 MATLAB 函数和工具箱函数。要在生成 C/C++ 代码之前识别和修复 MATLAB 代码的问题,您可以使用代码分析器和代码生成就绪工具进行检查。要检查您的 MATLAB 代码生成的代码是否符合预期,请生成并执行一个 MEX 函数,该函数可在 MATLAB 环境中执行和测试。

函数

coder.runTestRun test replacing calls to MATLAB functions with calls to MEX functions
coder.screener确定函数是否适合代码生成
getLineColumnFind locations of beginning and end of MATLAB code involved in code generation
textReportExport code generation readiness report to base workspace as a character vector (自 R2022a 起)

属性

coder.CallSite Properties Information about a function call site in your MATLAB code (自 R2022a 起)
coder.CodeFile PropertiesDescription of file containing text that is involved in code generation
coder.File PropertiesDescription of file without text that is involved in code generation
coder.Message PropertiesDescription of message produced during code generation readiness analysis or during code generation
coder.ScreenerInfo PropertiesCode generation readiness information (自 R2022a 起)

主题

MATLAB 代码分析基础知识

代码分析器

代码就绪工具

MEX 函数测试

故障排除