Change How Warnings Display
You can control how warnings appear in MATLAB by modifying two warning modes,
verbose and backtrace.
Mode Description Default
verbose Display a message on how to
suppress the warning.
off (terse)
backtrace Display a stack trace after a
warning is invoked.
on (enabled)
NoteThe verbose and backtrace modes present some limitations:
- prev_state does not contain information about the backtrace or verbose modes
in the statement, prev_state = warning('query','all'). - A mode change affects all enabled warnings.
Enable Verbose Warnings
When you enable verbose warnings, MATLAB displays an extra line of information with
each warning that tells you how to suppress it.
For example, you can turn on all warnings, disable backtrace, and enable verbose
warnings:
warning on all
warning off backtrace
warning on verbose
Running a command that produces an error displays an extended message:
rmpath('folderthatisnotonpath')
Warning: "folderthatisnotonpath" not found in path.
(Type "warning off MATLAB:rmpath:DirNotFound" to suppress this warning.)
Display a Stack Trace on a Specific Warning
It can be difficult to locate the source of a warning when it is generated from code buried
in several levels of function calls. When you enable the backtrace mode, MATLAB displays
26 Error Handling