Greek symbols in MATLAB GUI

5 次查看(过去 30 天)
How can i write a formula with Greek symbols, which I want to show in GUI: Formula M_o=C(\omega_m)^2
Please help me

采纳的回答

Walter Roberson
Walter Roberson 2015-10-30
Note: additional capabilities have been added for Unicode characters since the time that Question was written; in particular starting R2014b more can be done.

更多回答(2 个)

Adam
Adam 2015-10-30
hAxes = axes( 'Position', position, 'Visible', 'off' );
text( 0.1, 0.1, 'M_o=C(\omega_m)^2', 'Parent', hAxes );
will create you text on a GUI with symbols (in R2015b, I don't know if you need to set any extra settings in older versions)
The position variable will obviously contain the usual position data that you would use for positioning a standard uicontrol, but unless they have changed uicontrols do not allow symbols so this is a workaround because 'text' objects do, but they have to be created on an axes.

Joep
Joep 2015-10-30
编辑:Joep 2015-10-30
better is to use ^{....} instead of ^. \omega not work that is because your interpreter is set wrong. It should be on TeX. You can change it in the GUI builder or by using:
set(handle,'interpreter','tex')
  3 个评论
Joep
Joep 2015-10-30
You did not specify anything as handle. Example:
prompt = {'\mu'};
dlg_title = 'Input';
num_lines = 1;
def = {'150'};
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
answer = inputdlg(prompt,dlg_title,num_lines,def,options);
numberOfCells = str2double(answer{1});
clearvars prompt dlg_title num_lines def answer
You need to refer to the handle. I assume u know what handles are when you working with GUI otherwise you should watch a introduction of Doug, http://blogs.mathworks.com/videos/2013/02/13/gui-building-in-matlab/. He has multiple ones.
Joep
Joep 2015-10-30
Sorry my mistake. Unfortunately it seems Matlab doesn't use the same text drawing methods on graphs, which support LaTeX, as it does on GUI elements. Here is a webpage explaining a workaround: http://undocumentedmatlab.com/blog/customizing-matlab-labels/
Basically, you will need to manually determine where you want the text to be on your GUI in terms of pixel position, and length, and rewrite your equation in HTML instead of LaTeX.
In the GUIDE interface for your GUI, you will need to click the "Editor" button on the toolbar menu, and find the section:
function initialize_gui(fig_handle, handles, isreset)
You'll want to insert your labeling code before the:
% Update handles structure
guidata(handles.figure1, handles);

请先登录,再进行评论。

类别

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