I have the habit to use matlab with the -nodesktop
option, and I was wondering if it is possible to print warnings and errors in colors.
`
For the moment, I tried a few things
warning.m
, but those functions are built-in and I can't modify themI tried to follow this post and I had to create a folder @char
somewhere in my path with a function in there with something like this
function varargout = warning(varargin)
fprintf('\033[33m'):
[varargout{1:nargout}] = builtin('warning',varargin{:});
fprintf('\033[0m');
end
I tried not to use directly the warning
function because I would have an infinite loop. The problem is that some warnings (for example in the imshow
function) are called like this
warning(message('images:imshow:magnificationMustBeFitForDockedFigure'))
and it doesn't call the function in the @char
folder.
I also thought of creating another program that would call matlab and color it when it founds warnings or errors (or to call matlab with an intelligent shell command coloring the lines where warning
appears but it seems difficult).
Does anyone have an idea of how I could solve my problem ?
You'll need to also override the warning function for the @message class. See what happens when you run:
metaclass(message('images:imshow:magnificationMustBeFitForDockedFigure'))