代码验证
生成的代码、可追溯性和代码生成报告的行为验证
您可以对照原始 MATLAB® 代码对生成的 MEX 代码的输出进行测试,也可以基于 MATLAB 单元测试类创建自定义测试。您可以选择生成运行时错误检查,提醒您注意代码执行过程中出现的错误。
函数
codegen | 从 MATLAB 代码生成 C 或 C++ 代码 |
coder.config | 创建代码生成配置对象 |
coder.mfunctionname | Name of calling function or method (自 R2021b 起) |
coder.runTest | Run test replacing calls to MATLAB functions with calls to MEX functions |
主题
测试生成的代码
- 测试从 MATLAB 代码生成的代码
验证生成代码的数值行为。 - 验证 MATLAB Coder 中的 MEX 函数
将运行原始 MATLAB 函数的结果与运行 MEX 函数的结果进行比较。 - 在命令行中验证 MEX 函数
使用coder.runTest或codegen-test选项测试 MEX 函数。 - Unit Test Generated Code with MATLAB Coder
Run MATLAB unit tests on generated code. - Unit Test External C Code with MATLAB Coder
Run MATLAB unit tests on generated code that integrates external C code.
运行时错误检测
- Generate Standalone C/C++ Code That Detects and Reports Run-Time Errors
Generate standalone libraries and executables that detect and report run-time errors, such as out-of-bounds array indexing.
