engGetVariable crashes after MATLAB has quit

When using the MATLAB Engine interface, if the MATLAB process quits, engGetVariable(ep, "name") simply crashes (at least on OS X it does).
What is the best way to deal with this problem?
The only solution I can see is to do
engEvalString(ep, "")
to test whether MATLAB is still running before each single engGetVariable(). Is there a better way? I wish engGetVariable were smart enough to handle this situation and just return NULL if MATLAB is not running.

댓글 수: 1

Samuel Gray
Samuel Gray 2022년 3월 10일
you could run a test string against the Matlab workspace pointed to by the engine pointer
sprintf(tststr,"whos('myvar');\n") (or ~exists('myvar','var'))
engEvalStr(tststr...)
getBuffer (I forget the exact call)
get the console buffer string and see if it has the variable that you're looking to copy with GetVariable

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Call MATLAB from C에 대해 자세히 알아보기

제품

태그

질문:

2013년 2월 11일

댓글:

2022년 3월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by