Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silencing warning messages in MATLAB

Tags:

matlab

Sometimes, depending on the size of an image, when I call addframe in MATLAB to add 2D images to a video, I get the following warning message.

Warning: The frame height has been padded to be a multiple of four as required by the specified codec. In avifile.addframe at 127

My questions are:

  1. Are there any ways of silencing specific warnings like this? If so, is it possible to capture a warning in a variable in my code (i.e. similar to the try & catch exception mechanism) rather than having MATLAB print this warning in the command window?

  2. If the above is not possible. Is it there a way to silence all warnings in MATLAB temporarily?

like image 830
Amelio Vazquez-Reina Avatar asked Jul 11 '11 13:07

Amelio Vazquez-Reina


1 Answers

Using the warning command, you can silence either all warnings or specific warnings by ID:

WARNING('OFF', 'MSGID') and WARNING('ON', 'MSGID') disable and enable the display of any warning tagged with message identifier MSGID. (Use LASTWARN to determine the identifier of a warning, or use the WARNING VERBOSE feature described below.) WARNING is not case sensitive when matching message identifiers.

For more help on the warning command, type help warning in the MATLAB command line.

like image 120
You Avatar answered Sep 23 '22 07:09

You