Amelio Vazquez-Reina
Amelio Vazquez-Reina

Reputation: 96294

Silencing warning messages in 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?

Upvotes: 5

Views: 9678

Answers (1)

You
You

Reputation: 23774

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.

Upvotes: 9

Related Questions