- There is a function "getReport" which can be used to get the message displayed for an exception. Here's the link to the doc : https://www.mathworks.com/help/matlab/ref/mexception.getreport.html
- You can also log the command window text to a file using "diary" command. Here's the link to the doc : https://www.mathworks.com/help/matlab/ref/diary.html
Catching messages displayed on the command window
11 次查看(过去 30 天)
显示 更早的评论
When I try to connect to another program, and the user has not logged in, it starts printing these messages:
I know how to get the ones highlighted in red, using a try-catch routine. But how can I search for the ones in black? The ones that say "failed to connect using..."?
Is there a routine I can use to raise a flag when this events are registered on the command window of Matlab?
Thanks for your help!
0 个评论
回答(1 个)
Monika Phadnis
2020-2-18
These links may help to get the exception message displayed :
Hope this helps.
2 个评论
Monika Phadnis
2020-2-26
Try using the getReport function. You can put the code in try catch blocks and store the exception messages in variables.
A small example could be:
try
surf
catch exception
errorMsg = getReport(exception)
end
Here, errorMsg will have the error text stored.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!