Is there a way to disable all warning messages from command window

 Accepted Answer

warning off;
Although you might just want to disable the warning that is bothering you:
[msg, id] = lastwarn;
warning('off', id)

5 Comments

Thanks, do I need to put in the parfor statement to supress for each instance?
"Errors and warnings produced on workers are annotated with the worker ID and displayed in the client's Command Window in the order in which they are received by the client MATLAB.
The behavior of lastwarn is unspecified at the end of the parfor if used within the loop body."
http://www.mathworks.com/help/toolbox/distcomp/bq__cs7-1.html
One common warning i get has to do with the size of the images I am trying to display. When the image is larger than the window I am using (often in a UI), I get the warning. From a separate thread, I got a solution to turn off this specific warning message via the command:
warning('off', 'Images:initSize:adjustingMag');
However, the warning state does NOT persist between Matlab sessions.
For scripts or UI's it's easy, I include this statement at the opening function of the UI or at the start of the script. However, I'd like to turn off a few specific warnings (in particular this one) permanently.
Is there any way to make the warning state persistent?
You can take the attached file, which turns off several benign warnings, and call it from your startup.m file.
edit startup.m
Then put in
TurnOffAllWarnings
and save it. Make sure TurnOffAllWarnings is in your search path.
Or just make it a function inside the startup.m file (you will have to put "function startup()" as the first line of your startup.m file if you choose to embed this function inside that startup.m file.)

Sign in to comment.

More Answers (1)

In case you want to suppress warnings from all workers running in parallel (the above answers do not work in this case), use:
pctRunOnAll warning off

1 Comment

Note that the size of the "display" for parpool members is not generally the size of the display of the client; a quick test showed me that workers appear to be assigned virtual 1024 x 768 displays. Thus one might need to consider different strategies for imshow complaining about image being larger than window for workers than you would for the client. (The workers have no access to the client's display; the workers are working in a memory buffer of some kind.)

Sign in to comment.

Categories

Products

Community Treasure Hunt

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

Start Hunting!