C# matlab lost output after exit() call

1 view (last 30 days)
Scott on 9 Jan 2015
Answered: A Jenkins on 9 Jan 2015
I'm using the COM automation server to execute some matlab code from C#. Some of the matlab code quits using exit() calls. Unfortunately it seems like these calls kill the matlab window more or less immediately and so the original MLApp.Execute() call doesn't exit cleanly, but instead throws a COMException ("remote procedure call failed") and the output string is lost.
Is there any way of (a) determining if the the COMException was due to an exit call in the matlab code, and (b) gathering the output string after the exit call has been made?
Thanks, Scott

Answers (1)

A Jenkins
A Jenkins on 9 Jan 2015
In my experience, exit() kills MATLAB. I usually rewrite my code in such a way that I can just use a return from it instead so that I can collect the output string.
(I'm sure there may be reasons why you can't do this in your application. If so, then I am just commenting here so I will remember to look back if other people have better answers...)


Community Treasure Hunt

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

Start Hunting!

Translated by