Main Content

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

代码验证

生成的代码、可追溯性和代码生成报告的行为验证

生成代码后,检查源代码并输出结果以供验证。代码生成报告提供了一个交互式界面,用于检查生成的 C/C++ 源文件、生成的数据类型和其他代码细节。通过使用报告信息对象以编程方式访问代码生成报告中的信息子集。您可以对照原始 MATLAB® 代码对生成的 MEX 代码的输出进行测试,也可以基于 MATLAB 单元测试类创建自定义测试。您可以选择生成运行时错误检查,提醒您注意代码执行过程中出现的错误。

函数

codegenMATLAB 代码生成 C/C++ 代码。
coder.config创建 MATLAB Coder 代码生成配置对象
coder.runTestRun test replacing calls to MATLAB functions with calls to MEX functions
getLineColumnFind locations of beginning and end of MATLAB code involved in code generation
coder.ignoreConstPrevent use of constant value of expression for function specializations
coder.ignoreSizePrevent code generator from creating function specializations for constant-size expressions (自 R2019b 起)
coder.mfunctionnameName of calling function or method (自 R2021b 起)

coder.HardwareImplementationHardware-specific configuration parameters for C/C++ code generation from MATLAB code

对象

coder.MexCodeConfigConfiguration parameters for MEX function generation from MATLAB code
coder.CodeConfigConfiguration parameters for C/C++ code generation from MATLAB code
coder.EmbeddedCodeConfigConfiguration parameters for C/C++ code generation from MATLAB code with Embedded Coder

属性

coder.ReportInfo PropertiesCode generation report information
coder.Summary PropertiesSummary of code generation from MATLAB code
coder.File PropertiesDescription of file without text that is involved in code generation
coder.CodeFile PropertiesDescription of file containing text that is involved in code generation
coder.Function PropertiesDescription of MATLAB function used in code generation
coder.Method PropertiesDescription of method in a MATLAB class used in code generation
coder.Message PropertiesDescription of message produced during code generation readiness analysis or during code generation
coder.BuildLog PropertiesBuild logs produced during code generation (自 R2019b 起)

主题

代码生成报告

测试生成的代码

运行时错误检测

故障排除