Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: warning display control
Replies: 2   Last Post: May 7, 2013 2:18 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: warning display control
Posted: May 6, 2013 9:38 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
news:km82p5$ed3$1@newscl01ah.mathworks.com...
> I would like to catch a warning,

Usually "catch" is used in the context of an error, not a warning. Do you
want MATLAB to stop executing and enter debug mode (or just stop executing
that function, no debug mode) when a warning is issued or do you simply want
to stop it from being displayed?

> but do not want MATLAB displaying the message on the screen.
>
> I read the doc of warning(), lastwarn(), try/catch, and still can't find a
> way to do it.
>
> Can someone give a hint.


If you want to prevent the warning from displaying, use WARNING with the
'off' flag and the identifier of the warning you want to silence. [Don't do
"warning off" on its own if you can avoid it; that's using a nuclear bomb to
kill a fly.]
If you want to enter debug mode when the warning is issued, use DBSTOP.


% begin stopOnWarning.m
function stopOnWarning

dbstop if warning MATLAB:plot:IgnoreImaginaryXYPart

x = 1:10;
y = sin(x)+1i*cos(x);
plot(x, y)
z = x+y;
% end stopOnWarning.m


If you wanted to stop execution if a particular warning is issued in a
particular place, look at LASTWARN and then just RETURN if the warning you
wanted to stop execution was issued.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.