error output from python matlab engine

59 views (last 30 days)
Jeremy Rutman
Jeremy Rutman on 13 Jan 2016
Commented: Jeremy Rutman on 27 Jan 2016
I'd like to get better debug info than the 'matlab function cannot be evaluated' that I currently see from a complex matlab function being run from python using the python matlab engine. Is there some way to pipe extra matlab debug output to a file and/or get more info ?
Jeremy Rutman
Jeremy Rutman on 27 Jan 2016
pretty much anything beyond 'matlab function cannot be evaluated' would be great - i've been using
out = StringIO.StringIO()
err = StringIO.StringIO()
retvals = matlab_engine.myfunc(image_filename, nargout=3,stdout=out,stderr=err)
outstring = out.getvalue()
errstring = err.getvalue()
logging.debug('ml output:'+str(outstring)+'\n')
logging.debug('ml err output:'+str(errstring)+'\n')

Sign in to comment.

Answers (1)

Robert Snoeberger
Robert Snoeberger on 15 Jan 2016
You could get the last uncaught exception [1] and then call getReport [2] to get the error message for that exception.
>>> import matlab.engine
>>> eng = matlab.engine.start_matlab()
>>> # Do something that throws an exception...
>>> eng.eval('exception = MException.last;', nargout=0)
>>> eng.eval('getReport(exception)')

Community Treasure Hunt

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

Start Hunting!