Thread Subject: Changing color of specific text in a textbox?

Subject: Changing color of specific text in a textbox?

From: Keith Gould

Date: 4 Aug, 2009 18:42:05

Message: 1 of 1

This will either be really simple, or practically impossible. So lets say I have the following code...

str1=strcat('SD=', randomVar1);
str2=strcat('zscore=', randomVar2);
str3=strcat('R^2=', randomVar3);
set(textBox, 'String', [str1, char(10), str2, char(10), str3], 'BackgroundColor', [1 1 1], 'Position', [.84 .105 .135 sizestat], 'FontSize', 8, 'HorizontalAlignment', 'left');

This will create some textbox on my figure that will look sort of like this (presuming my text doesn't get mangled):
--------------------------------
| SD=X.XXX |
| zscore=-X.XXX |
| R^2=X.XXX |
--------------------------------

and of course, presume that I have some numerical values for randomVar1, 2 and 3... they've been represented as X.XXX or -X.XXX.

Since it's really hard to see the negative sign in the figure I would like to add colors to certain portions of the text in the textbox, but not all of it. Ideally, I want to color green for positive and red for negative values.

So im wondering if its possible to color a certain portion of the text such as just the "SD=X.XXX" section?

Thanks for any help in advance!!

-Keith

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
text box color Keith Gould 4 Aug, 2009 14:44:07
color Keith Gould 4 Aug, 2009 14:44:07
text color Keith Gould 4 Aug, 2009 14:44:07
text Keith Gould 4 Aug, 2009 14:44:06
rssFeed for this Thread

Contact us at files@mathworks.com