生成MEX文件时出现Matlab Codgen错误

时间:2018-02-20 12:25:24

标签: matlab codegen

我在使用Matlab Codgen生成MEX文件时遇到了一些问题。我无法确定此错误的原因,根据我的理解,我收到的错误消息并未反映真实情况。

我要转换的功能如下:

function section = locateCupPlanInSec(separatorInterval,currentAngle)

lowerSep = 1; 
upperSep = size(separatorInterval,2);
section = 0;    % init value

while (upperSep-lowerSep) > 1

    middleSep = (upperSep+lowerSep)/2;
    middleAngle = separatorInterval(:,middleSep);

    if currentSliceAngle > middleAngle
        lowerSep = middleSep; 
    else
        upperSep = middleSep;
    end

end

section = lowerSep;

其中currentAngle是double(1x1),separatorInterval是double(1x:inf)数组。当我使用codgen时,我在生成试用代码和构建MEX时没有遇到任何问题。但是在使用MEX运行测试文件时,我得到以下结果:

Error using TestBenchManager.executeTestBench (line 0)
Error evaluating test code.

Caused by: Undefined function or variable 'separatorInterval'.

Error in runTestExecute (line 0)

Error in runTestBench (line 0)

Error in runTestBench (line 0)

但是也定义了separatorInterval,我可以在工作区中看到它。我究竟做错了什么?感谢

0 个答案:

没有答案