What is the syntax for subscripts in a plot text box?

9 views (last 30 days)
I am working on a code to plot a function with a title and an annotation below the graph. So far everything is working smoothly -except- the subscript syntax [ '_' ] is only working in the title and not my annotation text box. i.e. EIF_2 is subscripted, but E_0, k_1, and k_{-1} is not. I'm at a loss. Any suggestions?
A few notes on my code: The annotation text box contains 3 lines of text and "prints" parameter values defined elsewhere in my .m file.
------------------------------------------------------------------------------
Here's the plotting portion of my code:
%Plot the solution
fig1=figure; %Create a new figure
h_axes = axes('parent',fig1,'position',[.1 .3 .8 .6]);
plot(h_axes,t,x(:,1),'r',t,x(:,2),'b',t,x(:,3),'g',t,x(:,4),'m',t,x(:,5),'--r',t,x(:,6),'--b',t,x(:,7),'--g',t,x(:,8),'--m',t,x(:,10),'k', t,x(:,11),'--k')
title(['EIF_2 Subfunction Model 4 -- (Initial PKR = ',num2str(x11),')'])
h_text=uicontrol('style','text','parent',fig1,'units','normalized','position',[.1 .05 .8 .1]);
set(h_text,'string',{[
'Initial Conditions: E_0 = ' ,num2str(E0),';'];
['Forward Parameters: k_1 = ',num2str(k1), ';'];
['Reverse Parameters: k_{-1} = ',num2str(k_1),';'];
})
xlabel('time')
ylabel('State Variable Values')
leg=legend('E_T', 'E_D', 'E_P', 'E_B','C_1','C_2','C_3','C_4','M','Pk','Location','NorthEastOutside');
-------------------------------------------------------------------------------
Any suggestions would be greatly appreciated!
-- Laura

Accepted Answer

Dan Seal
Dan Seal on 9 Jul 2013
UICONTROL objects do not support LaTeX or TeX markup. If you search "uicontrol tex" or "uicontrol latex" on Google, you will see links to several possible workarounds that people have found. These sometimes involve other functions that have been posted to the file exchange or other hacks with different types of graphics objects.
The easiest way to get TeX markup in your figure is just to use the TEXT command instead of the UICONTROL command. Be aware that a text object is the child of the axes, so it should be positioned based on the axes units.
  5 Comments
Laura
Laura on 9 Jul 2013
Okay - I'll look into that. Thanks again!
Laura
Laura on 9 Jul 2013
With some minor tweaking to my code it worked like a charm!

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!