How can I write Greek letters in a Static Text box in GUIDE in MATLAB 7.1 (R14SP3)?

14 vues (au cours des 30 derniers jours)
I would like to write Greek letters (or other LaTex symbols) like "alpha" in a Static Text Box in GUIDE.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 14 Mai 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_.

Plus de réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Produits


Version

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by