I would like to check if a function display a warning or not? Is it possible?
MATLAB: Is it possible to check warning message
checkfunctionmessagewarning
checkfunctionmessagewarning
x = bsxfun(@times, Cr, x2) %that's all that's needed. No loop.
function varargout = warning(varargin)persistent MsgListif isa(MsgList, 'double') MsgList = {};endif nargin == 2 && isempty(varargin{1}) && isa(varargin{1}, 'double')switch varargin{2} case 'GetList' varargout{1} = MsgList; return; case 'ResetList' MsgList = {}; return;end % No OTHERWISE!
varargout = cell(1, nargout);[varargout{:}] = builtin('warning', varargin{:});MsgList{length(MsgList) + 1} = lastwarn;
warning([], 'GetList')warning([], 'ClearList')
Best Answer