Main Content

texlabel

TeX representation of symbolic expression

Description

example

texlabel(expr)converts the symbolic expressionexprinto the TeX equivalent for use in character vectors.texlabelconverts Greek variable names, such as delta, into Greek letters. Annotation functions, such astitle,xlabel, andtextcan use the TeX character vector as input. To obtain the LaTeX representation, uselatex.

example

texlabel(expr,'literal')interprets Greek variable names literally.

Examples

Generate TeX Character Vector

Usetexlabelto 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 maketexlabelinterpret Greek variable names literally, include the argument'literal'.

texlabel(lambda12,'literal')
ans = '{lambda12}'

Insert TeX in Figure

Ploty = x^2usingfplot. Show the plotted expressionyby usingtexlabelto generate a TeX character vector thattextinserts into the figure.

symsxy = x^2; fplot(y) ylabel = texlabel(y); text(1, 15, ['y = 'ylabel]);

Figure contains an axes object. The axes object contains 2 objects of type functionline, text.

Input Arguments

collapse all

Expression to be converted, specified as a symbolic expression.

Version History

Introduced before R2006a