1

我正在使用 calllib 从 matlab 访问外部 DLL。DLL 中有一个函数,其签名如下所示:

typedef struct resultStruct {
    double E;
    double W;
    double N; 
    double S;
    double Z;
    double Y;
} RESULT_STRUCT;


typedef struct inputStruct {
    double A;  
    double B; 
    double C; 
} INPUT_STRUCT;

RESULT_STRUCT calc(
    const INPUT_STRUCT* input);

当我尝试在 matlab 中调用它时,

loadlibrary('calc.dll','calc.h');
input.A = 1;
input.B = 2;
input.C = 3;

[res, st] = calllib('calc','calc',input);

我得到错误:

??? Error using ==> calllib
The function return type is not supported.

令人惊讶的是,谷歌没有显示该错误消息,并且 calllib 的文档中没有任何内容:http: //www.mathworks.com/help/techdoc/ref/calllib.html

我的猜测是,由于该函数正在返回一个结构,因此 matlab 正在呕吐。但是文档中没有任何建议。尽管 matlab 没有提供任何示例,但都包含一个结构作为输出变量。

4

1 回答 1

1

我怀疑和你一样,即 MATLAB 不喜欢 struct 返回类型。尝试返回一个简单的类型,看看是否可行。然后我建议联系优秀的 MATLAB 支持人员。

于 2011-01-06T00:19:30.733 回答