is it possible to check warning message?

I would like to check if a function display a warning or not? Is it possible?

 Accepted Answer

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

Asked:

on 16 Mar 2015

Answered:

on 17 Mar 2015

Community Treasure Hunt

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

Start Hunting!