Tags: article, barry, color, comgt, fred, jeremy, ltf340a3c321, ltjbarry, mathworks, matlab, programming, questionfor, strings

color of strings

On Programmer » Matlab

1,762 words with 0 Comments; publish: Sun, 27 Apr 2008 00:46:00 GMT; (200125.00, « »)

In article <f340a3$c32$1.matlab.questionfor.info.fred.mathworks.com>,

Jeremy Barry <jbarry.matlab.questionfor.info.mathworks.com> top-posted:

[top-posting adjusted to make it easier to follow the discussion]

>"Andrea Schmidt" <external.Andrea.Schmidt.matlab.questionfor.info.de.bosch.com> wrote in message


>A simple way is to use error instead of using disp.

>help error

Hmmm, error does print out the text in red, but always red, no choice

of colours. And it has the side effect of throwing an error, which would

return control to the enclosing try/catch, or returning control to

the keyboard if there is no active try/catch.

There is no (documented) cross-platform method of choosing the

colour of text for disp(). The other poster mentioned a possibility

that works with xterm or equivilent, which I deduce makes use

of ANSI escape sequences; unfortunately that doesn't work in that

matlab GUI console.

If console output is not a strict requirement, then there are GUI hacks

such as:

ed = errordlg('What an error!');

edc = get(ed,'Children');


(An errordlg has three direct children; the first is an axes for

placement of the icon; the third is a uicontrol() for the OK button;

the second is an axes for placement of the text(). The text()

is thus the child of the second child of the errordlg; once it's

handle has been found, the usual text() properties can be set.)


Programming is what happens while you're busy making other plans.

All Comments

Leave a comment...