engGetVariable crashes after MATLAB has quit

3 vues (au cours des 30 derniers jours)
Szabolcs
Szabolcs le 11 Fév 2013
Commenté : Samuel Gray le 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 commentaire
Samuel Gray
Samuel Gray le 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Call MATLAB from C dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by