From: Jimmy on
Dear all,

I'm trying to display a set of a calculated values from a data set as a text box in a figure with the plotted data in the following way (note that the figure, axes, and plotted data are already displayed at this stage in the code):

mTextBox = uicontrol('Style','text');
set(0,'DefaultTextInterpreter','tex')
set(mTextBox,'String','test V_o\n \alpha')

What I expect now is Vo (with a subscript) and a Greek lower case letter alpha on the next line, but the TeX string doesn't get interpreted and the string "test V_o\n \alpha" is simply printed in my figure.

Alternatively I have tried set(mTextBox,'String',sprintf('test V_o\n \alpha')) which prints "V_oc (next line) [square]lpha", since TeX cannot be interpreted by sprintf .. so this doesn't do want I want either.

Does anyone how to solve this problem or is not possible to interpret TeX strings in uicontrol?

Thanks,
Jimmy.

PS I know that 'tex' is the default value for 'DefaultTextInterpreter' but since I switched it a few times earlier on in the program I had to put it back to 'tex'. Also, setting it to 'tex' again should not make a difference...
From: Doug Schwarz on
In article <hhu69f$cgt$1(a)fred.mathworks.com>,
"Jimmy " <jimmym(a)sundaysolar.net> wrote:

> Dear all,
>
> I'm trying to display a set of a calculated values from a data set as a text
> box in a figure with the plotted data in the following way (note that the
> figure, axes, and plotted data are already displayed at this stage in the
> code):

[snip]

Check out my uibutton:

<http://www.mathworks.com/matlabcentral/fileexchange/10743-uibutton-gui-p
ushbuttons-with-better-labels>

(Watch out for wrapped URL.)

Even though it is primarily written to create button uicontrols, it can
also create text boxes.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
From: Yair Altman on
"Jimmy " <jimmym(a)sundaysolar.net> wrote in message <hhu69f$cgt$1(a)fred.mathworks.com>...
> Dear all,
>
> I'm trying to display a set of a calculated values from a data set as a text box in a figure with the plotted data in the following way (note that the figure, axes, and plotted data are already displayed at this stage in the code):
>
> mTextBox = uicontrol('Style','text');
> set(0,'DefaultTextInterpreter','tex')
> set(mTextBox,'String','test V_o\n \alpha')
>
> What I expect now is Vo (with a subscript) and a Greek lower case letter alpha on the next line, but the TeX string doesn't get interpreted and the string "test V_o\n \alpha" is simply printed in my figure.
>
> Alternatively I have tried set(mTextBox,'String',sprintf('test V_o\n \alpha')) which prints "V_oc (next line) [square]lpha", since TeX cannot be interpreted by sprintf .. so this doesn't do want I want either.
>
> Does anyone how to solve this problem or is not possible to interpret TeX strings in uicontrol?


text uicontrols are very limited, and cannot display tex/HTML formatting (at least not out of the box). Instead, use the text(...) function.

Yair Altman
http://UndocumentedMatlab.com
From: Jimmy on
Thanks a lot for the tip, I didn't know about this difference between text and uicontrol. Something like this did the trick for me (rather than using uicontrol):

text('Position',[45 235],'String',['test V_o'; '\alpha'])

Note that it is not possible to get \n interpreted as a line feed with text; that's why I put the different lines for the printout in different cells of a string array.