Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Command Window Font Color

Subject: Command Window Font Color

From: Luke

Date: 2 Nov, 2007 09:58:52

Message: 1 of 4

Is it possible to output to the command window, in a
specfifc color, say by using disp, or fprintf.

For example:
I want to output font like PASS (in green), or FAIL (in
red).

Subject: Command Window Font Color

From: Yair Altman

Date: 2 Nov, 2007 10:42:12

Message: 2 of 4

"Luke " <luke.bagnall@airbus.com> wrote in message
<fgescs$hg8$1@fred.mathworks.com>...
> Is it possible to output to the command window, in a
> specfifc color, say by using disp, or fprintf.
>
> For example:
> I want to output font like PASS (in green), or FAIL (in
> red).

You can't control the color programatically, except the
following:

fprintf(2,'whatever') will print in red just like anything
else spilled into STDERR (FID=2). You can also use '<a
href=...>...</a>' to display something in blue underline. Of
course, if you change colors in the Preferences or
*.ColorPrefs, you'll get other colors, but this affects the
entire Command Window at once, not just text displayed from
now on.

There's probably an undocumented hack somewhere, but I
haven't found it yet (and my question to Kristin on this
went unanswered...)

Yair Altman
http://ymasoftware.com

Subject: Command Window Font Color

From: Luke

Date: 2 Nov, 2007 11:13:37

Message: 3 of 4

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<fgeuu4$ig6$1@fred.mathworks.com>...
> "Luke " <luke.bagnall@airbus.com> wrote in message
> <fgescs$hg8$1@fred.mathworks.com>...
> > Is it possible to output to the command window, in a
> > specfifc color, say by using disp, or fprintf.
> >
> > For example:
> > I want to output font like PASS (in green), or FAIL (in
> > red).
>
> You can't control the color programatically, except the
> following:
>
> fprintf(2,'whatever') will print in red just like anything
> else spilled into STDERR (FID=2). You can also use '<a
> href=...>...</a>' to display something in blue underline.
Of
> course, if you change colors in the Preferences or
> *.ColorPrefs, you'll get other colors, but this affects
the
> entire Command Window at once, not just text displayed
from
> now on.
>
> There's probably an undocumented hack somewhere, but I
> haven't found it yet (and my question to Kristin on this
> went unanswered...)
>
> Yair Altman
> http://ymasoftware.com
>

I wondered if you could change the preferences, but that's
no good if it changes everything. I'm sure there must be a
a crude way of forcing it.

Subject: Command Window Font Color

From: Yair Altman

Date: 13 May, 2009 14:03:01

Message: 4 of 4

After a very long investigation, I am proud to announce that I have solved the problem of displaying text in any color (with possible underline) in the Command Window. It works on all Matlab 7 versions.

Interested readers can find details here:
http://undocumentedmatlab.com/blog/cprintf-display-formatted-color-text-in-command-window/

Yair Altman
http://UndocumentedMatlab.com
 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us