is it possible to check warning message?

1 view (last 30 days)
I would like to check if a function display a warning or not? Is it possible?

Accepted Answer

Image Analyst
Image Analyst on 17 Mar 2015
Try using lastwarn:
% Initialize the global lastwarn variable to "Success"
lastwarn('Success')
% Some code that may or may not produce an error
a=10;
% Check if a warning was issued.
if strcmp(lastwarn, 'Success')
% All is well - no warning.
fprintf('All is well - no warning.\n');
else
% A warning was issued.
fprintf('A warning was issued..\n');
end

More Answers (0)

Categories

Find more on Argument Definitions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!