MATLAB: How to use Greek letters and subscripts in a GUI

gui

How to use Greek letters and subscripts in a GUI.
Using the code that works for a figure plot doesn't seem to work. I'm using the R2018a version.

Best Answer

If you are using App Designer, you need to set the interpreter to 'TeX' or 'LaTeX'. Unfortunately, only TickLabelInterpreter is available through the interface. To set other items, you need to do the following:
% For UIAxes Title, XLabel, or YLabel, this can only be accomplished programatically.
% That means you must set the interpreter and string in code - perhaps the startupFcn Callback
app.UIAxes.Title.Interpreter = 'latex';
app.UIAxes.Title.String = '$\int_{0}^{2} x^3\sin(x) dx$';
% For text objects:
text(app.UIAxes,0.5,0.5,'$\int_{0}^{2} x^3\sin(x) dx$','Interpreter','latex');
% For colorbar:
c = colorbar(app.UIAxes);
c.Label.Interpreter = 'latex';
c.Label.String = '$\int_{0}^{2} x^3\sin(x) dx$';
% For legend:
h = legend(app.UIAxes);
title(h,'$\int_{0}^{2} x^3\sin(x) dx$','Interpreter','latex');
All other components do not yet support interpreters (in 2018a).