How to supress a warning which does not have a corresponding warning ID.

2 ビュー (過去 30 日間)
Chetan Aswathanarayana
Chetan Aswathanarayana 2013 年 7 月 4 日
>> vxlib
Warning: 'vxlib' is obsolete, use 'vxlib1' instead.
If I were to supress a warning warning('off',id), I would need a corresponding ID. But the above does not have one, how could this be suppressed?
  3 件のコメント
Chetan Aswathanarayana
Chetan Aswathanarayana 2013 年 7 月 4 日
Yep I had tried that:
>> vxlib
Warning: 'vxlib' is obsolete, use 'vxlib1' instead.
>> [msg id] = lastwarn
msg =
'vxlib' is obsolete, use 'vxlib1' instead.
id =
''
But , the id in this case is empty :)
Image Analyst
Image Analyst 2013 年 7 月 4 日
Maybe try this instead:
warnStruct = warning('query', 'last')
will probably give the same thing, but might be worth a shot.

サインインしてコメントする。

回答 (2 件)

Jan
Jan 2013 年 7 月 4 日
編集済み: Jan 2013 年 7 月 4 日
I dare to ask, if it could be importamt mot to hide the message, but to follow the suggestion to use 'vxlib1' instead.
Sorry for mentioning this.
[EDITED] Let me mention this, althout I recommend not do this in productive code: You can shadow the builtin warning command by a user-defined function, which create automatic warn-IDs:
function Out = warning(varargin)
In = varargin;
if nargout
Out = builtin('warning', In{:});
else
if length(strfind(In{1}, ':') < 2) % ??? How to recognize the ID ???
autoKey = DataHash(In{1}, struct('Format', 'hex'));
In = cat(2, {['My:Id:', autoKey]}, In);
end
builtin('warning', In{:});
end
(Written in the forum's editor ==> not tested!!!)
See FEX: DataHash. Put this file into a folder, which appears in Matlab's path on the top.
Please note, that any bug in this code can suppress extremely important warning messages and I strongly recommend not to tinker on builtin functions without extremely good testing. Even then it will be very confusing if you run the same codes on another machine and get warnings, which are hidden on your home machine. Therefore I recommend either to edit the code of the function to insert the ID or follow the adviced changes to avoid the warning.
  2 件のコメント
Chetan Aswathanarayana
Chetan Aswathanarayana 2013 年 7 月 4 日
Well, Yes I should go for vxlib1 when such a warning pops up. But question here was more genral and the above was merely an example . We do have quite a few warnings in Matlab which aren't associated with ID's, and If I were to suppres it, how could that be addressed.
Jan
Jan 2013 年 7 月 4 日
See [EDITED].

サインインしてコメントする。


Hugo
Hugo 2013 年 7 月 4 日
Use
warning('off','comm:obsolete:vxlib');
It may ask you to unlock the library first in a popup window, which you can do by just clicking "unlock" in that same window.
  2 件のコメント
Chetan Aswathanarayana
Chetan Aswathanarayana 2013 年 7 月 4 日
Hello Hugo,Thanks and I tried the above and it didn't solve the problem. I still get the same problem, infact I didn't get any pop up to unlock the library.
Hugo
Hugo 2013 年 7 月 4 日
編集済み: Image Analyst 2013 年 7 月 4 日
Ok. What you can do then is:
s=warning('off','all');
vxlib
warning(s);
The first line turns off all warnings.
The second line starts vxlib.
The third line sets back all warnings in their previous state.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by