Warning Control Statements
Once you have the warning statements in your M-file code and are ready to execute the code, you can indicate how you want MATLAB to act on these warnings by issuing control statements. These statements place the specified warning(s) into a desired state and have the format
Control statements can also return information on the state of selected warnings. This only happens if you assign the output to a variable, as shown below. See Output from Control Statements.
There are three possible values for the
state argument of a warning control statement.
||Enable the display of selected warning message.
||Disable the display of selected warning message.
||Display the current state of selected warning.
In addition to the message identifiers already discussed, there are two other identifiers that you can use in control statements only.
||Set selected warning to the specified state.
||Set all warnings to the specified state.
||Set only the last displayed warning to the specified state.
MATLAB starts up with all warnings enabled, except for those that are displayed in response to the command, |
Example 1 -- Enabling a Selected Warning
Enable just the
actionNotTaken warning from Simulink by first turning off all warnings and then setting just that warning to
query to determine the current state of all warnings. It reports that you have set all warnings to
off with the exception of
Example 2 -- Disabling the Most Recent Warning
inv on zero displays a warning message. Turn off the most recently invoked warning with
warning off last.
|Warning Statements||Output from Control Statements|
© 1994-2005 The MathWorks, Inc.