在命令行中验证 MEX 函数
如果您有调用原始 MATLAB® 函数的测试文件,您可以使用 coder.runTest 在命令行中验证 MEX 函数。coder.runTest 运行测试文件,将对原始 MATLAB 函数的调用替换为对生成的 MEX 函数的调用。例如,这是对测试文件 myfunction_test 和函数 myfunction 的 coder.runTest 的调用
coder.runTest('myfunction_test', 'myfunction')
如果在使用 coder.runTest 运行期间发生错误,调试时可获得调用堆栈信息。
您也可以使用 codegen -test 选项。
codegen myfunction -test 'myfunction_test'
测试文件可以是 MATLAB 函数、脚本或基于类的单元测试。