Static text and greek letter
Afficher commentaires plus anciens
Hi,
how can I easy write "Set omega" into static text in GUI, where omega should be a greek letter?
Thanks for help
Réponse acceptée
Plus de réponses (1)
Timothy Plummer
le 4 Jan 2017
So there is an easier way to do this, but you need to know the Unicode number for the character you want, and preferably in decimal notation. The simplest way would be to call the Unicode number, which is typically shown in hexadecimal, and call:
Unicode = ''; %%insert Unicode
char(hex2dec(Unicode))
Char will output the Unicode character which can be inserted into the uicontrol correctly. So the code you would need would be:
uicontrol('style','text','string',['Set ',char(hex2dec('3a9'))]);
Let me know if this helps.
3 commentaires
Walter Roberson
le 5 Jan 2017
This depends on which MATLAB release you are using. In R2014a and earlier, characters beyond position 255 would never appear.
In R2014b and later, Unicode in uicontrol is supported, and you can even directly include the characters in the strings if you find a way to enter them. For example,
uicontrol('style','text', 'string', 'Set Ω', 'Units','norm','Position',[.1 .1 .3 .3])
However, whether Unicode characters will be saved in your .m files depends upon your MATLAB release and your operating system and your region settings, so coding in terms of char(hex2dec()) might be a practical necessity. Another approach is, for example,
uicontrol('style','text', 'string', sprintf('Set \x3a9'), 'Units','norm','Position',[.1 .1 .3 .3])
Diaa
le 7 Mar 2017
@Walter Roberson Could you refer me to the specific part of MATLAB documentation of printing characters like your approach?
\x3a9
Walter Roberson
le 7 Mar 2017
Diaa: see https://www.mathworks.com/help/matlab/ref/sprintf.html#input_argument_formatSpec and scroll to "Text Before or After Formatting Operators" in the Special Characters table, the entry
Character whose ASCII code is the hexadecimal number, N \xN
Catégories
En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!