How do I use Matlab engine in my code (for calling `engOpenSingleUse()`)?

北战南征 提交于 2019-12-01 22:23:13

As per the documentation that you linked to, the string argument to engOpenSingleUse is the "start" command - this is NOT a MATLAB command to be executed. engOpenSingleUse just starts the MATLAB engine- you have to call a different function to actually use the engine via engEvalString

Engine* matlabEngine = engOpenSingleUse(0, vpDcom, &iReturnValue);
engEvalString(matlabEngine, PlotCommand.c_str());

engOpenSingleUse just means the engine it starts can only be used by one application, not that it is going to execute a single command string.

From the docs:

C Syntax

#include "engine.h"
Engine *engOpenSingleUse(const char *startcmd, void *dcom,   int *retstatus);

Arguments:

startcmd String to start MATLAB process. On Microsoft Windows systems, the startcmd string must be NULL.

dcom Reserved for future use; must be NULL.

retstatus Return status; possible cause of failure.

Returns Microsoft Windows Operating Systems Only Pointer to an engine handle, or NULL if the open fails.

UNIX Operating Systems Not supported on UNIX systems.

For completeness, I'll mention that you should also check to make sure the engOpen call returned a non-NULL pointer before continuing with your program.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!