How can I write Greek letters in a Static Text box in GUIDE in MATLAB 7.1 (R14SP3)?
2 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2010-1-29
编辑: MathWorks Support Team
2018-5-14
I would like to write Greek letters (or other LaTex symbols) like "alpha" in a Static Text Box in GUIDE.
采纳的回答
MathWorks Support Team
2018-5-14
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!