Greek symbols in MATLAB GUI
9 次查看(过去 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
0 个评论
采纳的回答
Walter Roberson
2015-10-30
I recommend reading http://uk.mathworks.com/matlabcentral/answers/14751-greek-alphabet-and-latex-commands-not-a-question
Note: additional capabilities have been added for Unicode characters since the time that Question was written; in particular starting R2014b more can be done.
0 个评论
更多回答(2 个)
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.
0 个评论
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
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
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 Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!