Effacer les filtres
Effacer les filtres

Write sigma in uicontrol / text

27 vues (au cours des 30 derniers jours)
Zsolt Lord
Zsolt Lord le 24 Mai 2013
Commenté : Image Analyst le 11 Déc 2020
Right now, I'm trying to make a GUI, which calculates a certain sum, and I'd like to write a sigma sign, but for some reason, it's not working.
This is what I tried: uicontrol ('Style','text',... 'String','\sigma_1',... 'FontSize',25,... 'Position', [200 340 100 50]);
If I try copy-pasting a sigma sign off google, it just turns into a '?'.

Réponse acceptée

Sean de Wolski
Sean de Wolski le 24 Mai 2013
Use an annotation instead of a uicontrol. This offers a text interpreter property:
annotation(gcf,'textbox','String','\sigma_1', 'FontSize',25,'units','pix', 'Position', [200 340 100 50],'Interpreter','Tex');
  3 commentaires
patrick mumba
patrick mumba le 18 Mai 2016
please share how you did it
Image Analyst
Image Analyst le 18 Mai 2016
Capitalize sigma:
annotation(gcf,'textbox','String','\Sigma_1', 'FontSize',25,'units','pix', 'Position', [200 340 100 50],'Interpreter','Tex');

Connectez-vous pour commenter.

Plus de réponses (2)

Image Analyst
Image Analyst le 24 Mai 2013

laurent jalabert
laurent jalabert le 11 Déc 2020
Modifié(e) : laurent jalabert le 11 Déc 2020
For displaying \Theta in a gui
for Style text :
GE = char(hex2dec('03B8')); test = uicontrol('Style','text','String', GE)
For Style list :
GE = char(hex2dec('03B8')); test = uicontrol('Style','list','String', GE)
This is working.
Now, I am using PLOT with ylabel. Those ylabel contains greek characters, displayed correctly since Interpreter Tex is OK.
how can I display an array if ylabell{:} as a Style list in the uicontrol ?
I give an example :
ylabell{1}=('\Theta'); ylabell{2}='\Ree T_i*\gamma [C]' ;
test = uicontrol('Style','list','Position',[100 100 200 100],'FontSize',14,'max',10,...
'min',1,'String', ylabell)
The problem is that Interpreter Tex is not a uicontrol class property. So it is impossible to have the same rendering of the greek character in uicontrol such as in ylabl axis of the graph.
So how to solve this problem when the Style list contains 80 different items containing greek characters ?
If I have to convert each greek character using char(hex2dec(' 03B8')), it is a bit fastidious isn't it ?
Strangely, a possible answer is to copy paste Δ instead of \Delta ... and it works both for ylabel and uicontrol list ...

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by