Restore Warnings
MATLAB allows you to save the on-off warning states, modify warning states, and
restore the original warning states. This is useful if you need to temporarily turn off some
warnings and later reinstate the original settings.
The following statement saves the current state of all warnings in the structure array
called orig_state:
orig_state = warning;
To restore the original state after any warning modifications, use this syntax:
warning(orig_state);
You also can save the current state and toggle warnings in a single command. For
example, the statement, orig_state = warning('off','all'); is equivalent to the
commands:
orig_state = warning;
warning('off','all')
Disable and Restore a Particular Warning
This example shows you how to restore the state of a particular warning.
1 Query the Control:parameterNotSymmetric warning:
warning('query','Control:parameterNotSymmetric')
The state of warning 'Control:parameterNotSymmetric' is 'on'.
2 Turn off the Control:parameterNotSymmetric warning:
orig_state = warning('off','Control:parameterNotSymmetric')
orig_state =
identifier: 'Control:parameterNotSymmetric'
state: 'on'
orig_state contains the warning state before MATLAB turns
Control:parameterNotSymmetric off.
3 Query all warning states:
Restore Warnings