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

Rebecca Krosnick
Rebecca Krosnick 2015년 12월 24일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2015년 12월 22일

댓글:

2015년 12월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by