Take the 2-minute tour ×

I am trying to color some alphabets in a string based on input alphabet given. Can anyone suggest me how to achieve it ? As I am new to this.

Suppose that I have the following string: "AUSTRALIA"

OUTPUT: (A in red)'A'USTR(A in red)'A'LI(A in red)'A'

share|improve this question
Where do you want to output? MATLAB command line? GUI? Web page? –  yuk Jan 10 '12 at 21:43
Welcome to SO. Show us the code you have so far, and consider changing the question title to something more descriptive. –  Richie Cotton Jan 10 '12 at 22:02
add comment

1 Answer

up vote 5 down vote accepted

If you want to show it as text on axes (GUI), use the text command and Latex formatted strings

text('string','{\color{red} A}ustralia')

You can read about Latex commands here.
Alternatively, there is an undocumented functionality for some UI controls, mentioned in Yair Altmans great website.

That is the way to do it (Taken directly from his site)


In order to actually find the letters instances, use the strrep command.


There is a flaw here, related to capital letter, I am sure that you can work it out!

share|improve this answer
add comment

Your Answer


