How to write Latex in GUI's label?

I want to write latex in Matlab's GUI labels. For example:
I have tried \theta, and with $ on both sides, but it does not work. Could someone please tell me how to solve this question? Thanks.

2 Comments

The 'interpreter' property doesn't appear to exist so looks like can't be done.
In 2020b it doesn't exist from the design view options but the property does exist and is editable from the code.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 25 Jan 2021
Edited: Adam Danz on 25 Jan 2021
From the startup function of your app, set the Edit Field Label's interpreter property to latex. You may need to reassign the string too.
function startupFcn(app)
app.thetaPoint1EditFieldLabel.Interpreter = 'latex';
app.thetaPoint1EditFieldLabel.Text = '$\theta$ of point';
end
Result:

4 Comments

Hi, I am using app designer to write my GUI. What you said is in
function createcomponent(app)
in the GUI.
However, I couldn't change the code in this part as they are somehow fixed.
I couldn't find where to change the interpreter in the Inspector of the text label either.
Could you please tell me if there is an alternative way to set the interpreter?
Adam Danz
Adam Danz on 25 Jan 2021
Edited: Adam Danz on 28 Jan 2021
My advice suggested you add that code within the startup function, not the area that you pointed out.
If your app doesn't already have a startup function, you have to add one. I'll update my answer to include instructions how to add a startup function.
Hi Adam, I tried using your instructions but Matlab returned an error saying that there is no property called 'interpreter'. The Matlab version I am using is R2019b and could you please tell me what I should do to fix this? Thanks
Adam Danz
Adam Danz on 11 Feb 2021
Edited: Adam Danz on 11 Feb 2021
App designer gets more support and features with every new release since it became available. I don't know when the interpreter property was first supported for this object but I do know it works in r2020b and the result is shown in my answer. You could update to r2020b. Otherwise, there is no solution I'm aware of.

Sign in to comment.

Categories

Asked:

on 25 Jan 2021

Edited:

on 11 Feb 2021

Community Treasure Hunt

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

Start Hunting!