在MATLAB中静默警告消息 [英] Silencing warning messages in MATLAB
问题描述
有时,当我致电 <在MATLAB中c0> 将2D图像添加到视频中,我收到以下警告消息.
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.
警告:框架高度已被填充为四的倍数,例如 指定编解码器所需. 在127的avifile.addframe中
Warning: The frame height has been padded to be a multiple of four as required by the specified codec. In avifile.addframe at 127
我的问题是:
-
有没有办法像这样使特定警告静音?如果是这样,是否有可能在我的代码的变量中捕获警告(即类似于try& catch异常机制),而不是让MATLAB在命令窗口中打印此警告?
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?
如果以上都不可行.是否可以通过暂时使所有警告静默?
If the above is not possible. Is it there a way to silence all warnings in MATLAB temporarily?
推荐答案
使用warning
命令,您可以按ID静默所有警告或特定警告:
Using the warning
command, you can silence either all warnings or specific warnings by ID:
WARNING('OFF', 'MSGID')
和WARNING('ON', 'MSGID')
禁用并启用 显示带有消息标识符MSGID
的任何警告. (使用LASTWARN
确定警告的标识符,或使用WARNING VERBOSE
功能 如下所述.)WARNING
在匹配消息时不区分大小写 标识符.
WARNING('OFF', 'MSGID')
andWARNING('ON', 'MSGID')
disable and enable the display of any warning tagged with message identifierMSGID
. (UseLASTWARN
to determine the identifier of a warning, or use theWARNING VERBOSE
feature described below.)WARNING
is not case sensitive when matching message identifiers.
有关warning
命令的更多帮助,请在MATLAB命令行中键入help warning
.
For more help on the warning
command, type help warning
in the MATLAB command line.
这篇关于在MATLAB中静默警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!