Clear Filters
Clear Filters

engGetVariable crashes after MATLAB has quit

1 view (last 30 days)
Szabolcs
Szabolcs on 11 Feb 2013
Commented: Samuel Gray on 10 Mar 2022
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 Comment
Samuel Gray
Samuel Gray on 10 Mar 2022
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

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!