From: Daniele on 16 Sep 2009 11:50 Hello, I was wondering if it's possible to redirect warning messages from the console, where they usually appear, to a textbox in a GUI. Thanks, Dan
From: Matt Fig on 16 Sep 2009 12:42 This could be done by first turning off the warning of concern, then setting the last warning to empty with lastwarn and finally checking lastwarn when appropriate to see if a warning has been thrown and placing the string in the 'string' property of the textbox. % This at the beginning of the code: lastwarn('') warning('off','MATLAB:singularMatrix') % Sometime later a call to inv is made: T = inv(ones(3)); % Normally a warning would be thrown at command prompt str = lastwarn lastwarn('') % Reset for possible 'next run' of code. if ~isempty(str) set(txthandle,'string',str) end You may want to do a cleanup after the code is run to restore the state of any warnings turned off during your code's execution.
From: Loren Shure on 17 Sep 2009 11:45 In article <h8r4hm$m5f$1(a)fred.mathworks.com>, spamanon(a)yahoo.com says... > This could be done by first turning off the warning of concern, then setting the last warning to empty with lastwarn and finally checking lastwarn when appropriate to see if a warning has been thrown and placing the string in the 'string' property of the textbox. > > % This at the beginning of the code: > lastwarn('') > warning('off','MATLAB:singularMatrix') > > % Sometime later a call to inv is made: > T = inv(ones(3)); % Normally a warning would be thrown at command prompt > str = lastwarn > lastwarn('') % Reset for possible 'next run' of code. > > if ~isempty(str) > set(txthandle,'string',str) > end > > > You may want to do a cleanup after the code is run to restore the state of any warnings turned off during your code's execution. > also check warndlg. It may help you. -- Loren http://blogs.mathworks.com/loren
|
Pages: 1 Prev: Associating event function with a variable Next: Overwrite multiple console output lines |