我正在尝试从 C 应用程序调用用户定义的 MATLAB 函数,但即使是最简单的引擎场景也无法正常工作。下面是一个应该简单地打印a = 1
到 MATLAB 命令窗口的程序。但是当我运行它时,什么也没有发生!
#include "engine.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
Engine *ep;
if (!(ep = engOpen("\0"))) {
fprintf(stderr, "\nCan't start MATLAB engine\n");
return EXIT_FAILURE;
}
engOutputBuffer(ep, NULL, 0);
engEvalString(ep, "a = 1");
engClose(ep);
return EXIT_SUCCESS;
}