How do I suppress warning messages from MATLAB ?

981 views (last 30 days)
I wish to suppress warning messages from MATLAB.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Jul 2021
Edited: MathWorks Support Team on 21 Jul 2022 at 14:06
You can selectively enable or disable specific warning messages, as long as they have been given a message identifier, with the WARNING function using the state and 'message_id' input arguments. You can suppress all warning messages using the 'off' state option, with the argument 'all' in place of a message identifier. You can suppress only the last warning message in a similar manner, replacing 'all' with 'last'. Once you have suppressed warnings, you can enable the warning messages again using the 'on' state option.
For more information on the WARNING function and message identifiers, please refer to the following documentation:

More Answers (2)

Billy on 19 Jun 2014

Cameron Grace
Cameron Grace on 20 Nov 2021
The answer given is far more complicated than necessary.
1.) Just go to preferences which can be found "Home/Environment/Preferences"
2.) Selected Code Analyzer from the tabs on the left.
3.) Wait for the analyzer to complete. You should see a percentage begin to increase from 0-100%
4.) Search for your warning in the search box
5.) Unselect your warning by clicking the box to deselect it. You want no check mark. Then select Apply in the bottom right.
This is way easier than going through an entire document page and attempting to code out a warning message. Honestly, not everyone is a programmer Mathworks SMH. Though you should look at your warnings carefully.
Best of luck!
  1 Comment
Steven Lord
Steven Lord on 20 Nov 2021
The process you've described will prevent Code Analyzer's static analysis from flagging a particular condition in your code. It will not prevent warning messages that are issued at runtime (using the warning function) from being thrown and displayed in the Command Window. To prevent those runtime warnings from being issued, you need to disable them with the warning function as per the @MathWorks Support Team answer.

Sign in to comment.


No tags entered yet.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!