LaTex for Titles in Appdesigner now possible?

9 Ansichten (letzte 30 Tage)
Niklas Kurz
Niklas Kurz am 24 Feb. 2022
Kommentiert: Cris LaPierre am 25 Feb. 2022
I'm now finding into appdesigner myself and have saw multiple people asking how to incorporate LaTex.
There are some workaround like
text(app.UIAxes,200,1.2,'Plot of','Interpreter','latex')
but using this as title is hard to align so I strive for an inbuilt adaption, resolving this issue.
Also, I want to update the title dependent on user input. How am I supposed to do that? The plain solution I've found is by:
app.UIAxes.Title.String = "Plot of "+ double(app.CEditField.Value) + "*sin(" + double(app.mEditField.Value) + "*x)"
Can't it be shorter? Also it lacks the primordial desire to choose LaTex interpreter.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 24 Feb. 2022
The easiest way to set the interpreter to LaTeX for a title is to use the 'interpreter' name-value pair.
title(app.UIAxes,'title string','Interpreter','latex')
However, there is no LaTeX markup in your title string, so it will still just display as text. What is the LaTeX expression you are wanting to create?
  4 Kommentare
Niklas Kurz
Niklas Kurz am 25 Feb. 2022
Bearbeitet: Niklas Kurz am 25 Feb. 2022
I've accepted this answere even though
C = app.CEditField.Value
m = app.mEditField.Value
are not updated when choosing different values in the Edit Field.
I tried using
title(app.UIAxes,'$$C\,\sin(m\,x)$$','Interpreter','latex')
%and
title(app.UIAxes,'$C\,\sin(m\,x)$','Interpreter','latex')
but no big difference there. C and m are displayed as text and not their Value.
Cris LaPierre
Cris LaPierre am 25 Feb. 2022
Vaules displayed in purple are text and not variables. You need to do something like what you were doing before if you want to use the values of C and m and not the letters C and m.
I might write my callback functions for each edit field like this.
% Value changed function: mEditField
function mEditFieldValueChanged(app, event)
C = app.CEditField.Value;
m = app.mEditField.Value;
title(app.UIAxes,"Plot of $"+ C + "*\sin(" + m + "*x)$",'Interpreter','latex')
end
% Value changed function: CEditField
function CEditFieldValueChanged(app, event)
C = app.CEditField.Value;
m = app.mEditField.Value;
title(app.UIAxes,"Plot of $"+ C + "*\sin(" + m + "*x)$",'Interpreter','latex')
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by