Get matlab error and warning text in C#

As the title states. I am looking for a way to retrieve both warning and error message when Matlab throws an exception while running in C#. Any input would be appreciated as all I am currently able to produce are the normal warnings.
The warnings mentioned above are the ones appearing in orange text inside Matlabs command window

1 comentario

Rebecca Krosnick
Rebecca Krosnick el 24 de Dic. de 2015
Did you compile your MATLAB code into a .NET assembly and now you are using the .NET assembly in a C# application? Alternatively, are you using MATLAB Engine to call MATLAB functions from your C# application?
My understanding is that you are using the MATLAB deployed .NET assembly in a C# application. In this case, I believe the exception object generated in the C# try/catch should include a message property that contains the error message. This exception object will not contain warning messages, though, since a "catch" will not be triggered by a warning.
In order to capture warning messages, you can use the "lastwarn" function: http://www.mathworks.com/help/matlab/ref/lastwarn.html
If you expect a warning to have occurred after a particular function call, you can call the "lastwarn" function to capture the warning message.
I do not think there is a way to specifically listen for warnings, however.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Preguntada:

el 22 de Dic. de 2015

Comentada:

el 24 de Dic. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by