Programming Previous page   Next Page

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.

Warning States

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.

Message Identifiers

In addition to the message identifiers already discussed, there are two other identifiers that you can use in control statements only.

msg_id string
Set selected warning to the specified state.
Set all warnings to the specified state.
Set only the last displayed warning to the specified state.

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 on.

Use query to determine the current state of all warnings. It reports that you have set all warnings to off with the exception of Simulink:actionNotTaken.

Example 2 -- Disabling the Most Recent Warning

Evaluating inv on zero displays a warning message. Turn off the most recently invoked warning with warning off last.

Previous page  Warning Statements Output from Control Statements Next page

© 1994-2005 The MathWorks, Inc.