MATLAB For Dummies
Book image
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 authors:

John Paul Mueller is an author and technical editor with experience in application development, database management, machine learning, and deep learning. He has written hundreds of books and articles helping everyday people learn everything from networking to database management.

John Mueller has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services (AWS). Luca Massaron, a Google Developer Expert (GDE),??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques.

This article can be found in the category: