How can I write Greek letters in a Static Text box in GUIDE in MATLAB 7.1 (R14SP3)?
5 views (last 30 days)
Show older comments
MathWorks Support Team
on 29 Jan 2010
Edited: MathWorks Support Team
on 14 May 2018
I would like to write Greek letters (or other LaTex symbols) like "alpha" in a Static Text Box in GUIDE.
Accepted Answer
MathWorks Support Team
on 14 May 2018
UICONTROLs do not support TeX or LaTeX symbols.
To work around this limitation, one can use a TEXT object which does support LaTeX. Note that the TEXT object is not accessible in GUIDE though. Therefore you can use the following piece of code in your figure's OpeningFcn to automatically replace certain Static Text UICONTROLs with TEXT objects:
% 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
Place this piece of code right before the following line in the OpeningFcn:
% Update handles structure
guidata(hObject, handles);
Further in GUIDE give the Static Text boxes which need to be rendered using LaTeX, a 'Tag' which starts with latex_.
0 Comments
More Answers (0)
See Also
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!