フィルターのクリア

Displaying special characters in dialog box

12 ビュー (過去 30 日間)
Christo van Rensburg
Christo van Rensburg 2019 年 7 月 13 日
回答済み: dpb 2019 年 7 月 13 日
Hi there
I'm trying to display certain special characters in brackets in a dialog box. The common way of doing it doesn't work for me, i.e. '\theta' or whatever the character may be. I'm writing the characters in a cell array.
My code is:
prompt = {'Air Temperature [celsius]', 'Firing Angle [degrees]', 'Lattitude [degrees]'};
The text in bold above is where I cannot insert the characters necessary.
Thanks in advance.

回答 (1 件)

dpb
dpb 2019 年 7 月 13 日
Dialogs don't have 'Interpreter' property, unfortunately, and they're not full-blown text objects underneath. Have to hardcode the ASCII code into the string.
circ=char(176); % dependent upon locale/system for specific character value
T=27.5;
A=23;
L=33.3;
prompt = sprintf(['Air Temperature ' circ 'C %.1f Firing Angle %d' circ ' Lattitude %0.1f' circ],T,A,L);
Modifying the example slightly for dialog
function myprompt
circ=char(176);
prompt = sprintf(['Air Temperature %.1f' circ 'C Firing Angle %d' circ ' Lattitude %0.1f' circ],27.5,23,33.3);
d = dialog('Position',[300 300 350 150],'Name','My Dialog', ...
'WindowStyle','normal');
txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[20 80 300 40],...
'String',prompt);
btn = uicontrol('Parent',d,...
'Position',[130 20 70 25],...
'String','Close',...
'Callback','delete(gcf)');
end
looks pretty close...

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by