Static text and greek letter

조회 수: 10 (최근 30일)
john
john 2013년 4월 6일
댓글: Walter Roberson 2017년 3월 7일
Hi,
how can I easy write "Set omega" into static text in GUI, where omega should be a greek letter?
Thanks for help

채택된 답변

Walter Roberson
Walter Roberson 2013년 4월 6일
편집: Walter Roberson 2013년 4월 8일
The easiest is to use a text() control instead of uicontrol('Style','text'). For text() controls, see http://www.mathworks.co.uk/matlabcentral/answers/14751-greek-alphabet-and-latex-commands-not-a-question
If you must use a uicontrol, then unless there is a method at the java level, you cannot do it with Style 'text' or 'edit'. You can, however, use 'style' 'Push' with 'enable' 'off', and then use html, such as
h = uicontrol('Style', 'push', 'enable', 'off', 'units', 'norm', 'position', [0 0 1 .1], 'String','<FONT COLOR="red">hello &omega;')
  댓글 수: 8
john
john 2013년 4월 8일
ok, thanks, it works
Miguel
Miguel 2016년 3월 17일
Do you know how to remove the border of that push button which is inside the uicontrol?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Timothy Plummer
Timothy Plummer 2017년 1월 4일
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
Diaa
Diaa 2017년 3월 7일
@Walter Roberson Could you refer me to the specific part of MATLAB documentation of printing characters like your approach?
\x3a9
Walter Roberson
Walter Roberson 2017년 3월 7일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by