MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Thread Subject: LaTex in static text field of a GUI using Matlab GUIDE

 Subject: LaTex in static text field of a GUI using Matlab GUIDE From: Aaronne Date: 25 Jun, 2012 11:31:07 Message: 1 of 6 Hi all, I am trying to insert a LaTeX symbol in a label in a GUI. I have created the GUI in GUIDE, but cannot seem to get symbols like alpha, phi etc in a static text field. Should this be done in the property inspector or in the .m file? I have tried a solution as: http://www.mathworks.co.uk/support/solutions/en/data/1-1VE03X/index.html?product=ML&solution=1-1VE03X But it just gives a mess of everything in the GUI. Any ideas? Thank you and best regards, Aaronne.
 Subject: LaTex in static text field of a GUI using Matlab GUIDE From: matt dash Date: 25 Jun, 2012 15:29:08 Message: 2 of 6 "Aaronne" wrote in message ... > Hi all, > > I am trying to insert a LaTeX symbol in a label in a GUI. > I have created the GUI in GUIDE, but cannot seem to get symbols like alpha, phi etc in a static text field. Should this be done in the property inspector or in the .m file? > > I have tried a solution as: > http://www.mathworks.co.uk/support/solutions/en/data/1-1VE03X/index.html?product=ML&solution=1-1VE03X > > But it just gives a mess of everything in the GUI. Any ideas? > > Thank you and best regards, > Aaronne. As the solution link is trying to suggest, you can't display latex on a uicontrol. Instead you need to make an invisible axes and put a text object in the axes. (make the axes in GUIDE and the text object in the m file)
 Subject: LaTex in static text field of a GUI using Matlab GUIDE From: Aaronne Date: 25 Jun, 2012 16:02:06 Message: 3 of 6 Hi Matt, Thanks for your reply, but I still not get it. I have put the codes in right place of my GUI_figure.m file. Then I also create a 'static text' object in the GUIDE .fig, and change the 'tag' to something start with 'latex_'. However, nothing happens but the added codes just give a mess of the whole GUI. Or do you mean that we need to add an 'axes object' in the GUIDE .fig? >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % TEXT annotations need an axes as parent so create an invisible axes which % is as big as the figure handles.laxis = axes('parent',hObject,'units','normalized','position',[0 0 1 1],'visible','off'); % Find all static text UICONTROLS whose 'Tag' starts with latex_ lbls = findobj(hObject,'-regexp','tag','latex_*'); for i=1:length(lbls) l = lbls(i); % Get current text, position and tag set(l,'units','normalized'); s = get(l,'string'); p = get(l,'position'); t = get(l,'tag'); % Remove the UICONTROL delete(l); % Replace it with a TEXT object handles.(t) = text(p(1),p(2),s,'interpreter','latex'); end >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 Subject: LaTex in static text field of a GUI using Matlab GUIDE From: matt dash Date: 25 Jun, 2012 16:19:07 Message: 4 of 6 "Aaronne" wrote in message ... > Hi Matt, > > Thanks for your reply, but I still not get it. > > I have put the codes in right place of my GUI_figure.m file. > > Then I also create a 'static text' object in the GUIDE .fig, and change the 'tag' to something start with 'latex_'. However, nothing happens but the added codes just give a mess of the whole GUI. > > Or do you mean that we need to add an 'axes object' in the GUIDE .fig? > Yes. You need to make an axes object instead of a static text uicontrol object. The tag has nothing to do with it... that's just a poorly chosen example in the link.
 Subject: LaTex in static text field of a GUI using Matlab GUIDE From: Aaronne Date: 25 Jun, 2012 16:31:06 Message: 5 of 6 Quite confusing now... I thought the 'tag' is used to find the object we need to give latex string for the text. So, currently, I put an 'axes' object on my GUI using GUIDE. Then may I ask what I need to do? How can I get a 'pi' show up in the 'axes' object? Thanks so much if you can give me some tips. Aaronne.
 Subject: LaTex in static text field of a GUI using Matlab GUIDE From: matt dash Date: 25 Jun, 2012 18:12:06 Message: 6 of 6 "Aaronne" wrote in message ... > Quite confusing now... > > I thought the 'tag' is used to find the object we need to give latex string for the text. > > So, currently, I put an 'axes' object on my GUI using GUIDE. Then may I ask what I need to do? > > How can I get a 'pi' show up in the 'axes' object? Thanks so much if you can give me some tips. > > > Aaronne. Just look at what the code you posted is doing. It finds each uicontrol with the "latex" tag. Then it deletes it (actually does this towards the end), and replaces it with an invisible axes that contains a text object that displays the desired text. Here is an example contrasting the two approaches: f=figure %uicontrols can't display latex: u=uicontrol('units','pixels','position',[20 200 200 24],...     'style','text','string','I can''t display \pi',...     'horiz','left',...     'backgroundcolor',get(f,'color')); %but text objects can: axes('units','pixels','position',[20 100 200 24],'visible','off') text(0,0.5,'I can display $\pi$','interpreter','latex',...     'horiz','left','vert','middle')