texlabel
TeX representation of symbolic expression
Description
texlabel(
converts the symbolic expressionexpr
)expr
into the TeX equivalent for use in character vectors.texlabel
converts Greek variable names, such as delta, into Greek letters. Annotation functions, such astitle
,xlabel
, andtext
can use the TeX character vector as input. To obtain the LaTeX representation, uselatex
.
Examples
Generate TeX Character Vector
Usetexlabel
to generate TeX character vectors for these symbolic expressions.
syms x y lambda12 delta texlabel(sin(x) + x^3) texlabel(3*(1-x)^2*exp(-(x^2) - (y+1)^2)) texlabel(lambda12^(3/2)/pi - pi*delta^(2/3))
ans = '{sin}({x}) + {x}^{3}' ans = '{3} {exp}(- ({y} + {1})^{2} - {x}^{2}) ({x} - {1})^{2}' ans = '{\lambda_{12}}^{{3}/{2}}/{\pi} - {\delta}^{{2}/{3}} {\pi}'
To maketexlabel
interpret Greek variable names literally, include the argument'literal'
.
texlabel(lambda12,'literal')
ans = '{lambda12}'
Insert TeX in Figure
Ploty = x^2
usingfplot
. Show the plotted expressiony
by usingtexlabel
to generate a TeX character vector thattext
inserts into the figure.
symsxy = x^2; fplot(y) ylabel = texlabel(y); text(1, 15, ['y = 'ylabel]);