Home

How to Set Warning Message Modes in MATLAB

|
Updated:  
2016-03-26 08:22:17
|
From The Book:  
MATLAB For Dummies
Explore Book
Buy On Amazon

Error messages always provide you with any details that the application provides. Warning messages are different — you can tell MATLAB to provide only certain details as needed. You can set the configuration globally or base it on the message identifier (so that warnings with some identifiers provide more information than others do). To set the global configuration, you provide two arguments. The first is the warning state:

  • on: Sets the configuration element on.

  • off: Turns the configuration element off.

  • query: Determines whether the configuration element is currently on or off.

At a global level, you have access to two settings, which are provided as the second argument to the warning() function:

  • backtrace: Determines whether the output includes stack trace information.

  • verbose: Determines whether the output includes a short message or one with all the details as well.

To see how this works, type warning(‘query', ‘backtrace') and press Enter. You should see an output message telling you the current status of the backtrace configuration element. (The default setting turns it on so that you can see the stack trace as part of the warning message when a stack trace is provided.)

The message identifier-specific form of the warning() function starts with a state. However, in this case, the second argument is a message identifier. For example, if you type warning(‘query', ‘MATLAB:FileIO:InvalidFid') and press Enter, you see the current state of the MATLAB:FileIO:InvalidFid identifier.

Setting warnings for particular message identifiers to off is usually a bad idea because the system can’t inform you about problems. This is especially true for MATLAB-specific messages (rather than custom messages that you create). However, setting them to off during troubleshooting can help you avoid the headache of seeing the message all the time.

About This Article

This article is from the book: 

About the book author:

Jim Sizemore is Professor of Physics and Engineering at Tyler Junior College. For over 25 years he s worked in the semiconductor and software industries as a process engineer, device physicist, and software developer and has been teaching college physics, engineering, and math for the last 13 years.

John Paul Mueller is a freelance author and technical editor. He has writing in his blood, having produced 100 books and more than 600 articles to date. The topics range from networking to home security and from database management to heads-down programming. John has provided technical services to both Data Based Advisor and Coast Compute magazines.