From: Daniele on
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
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
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