Latex function in Matlab

I want to use latex function in Matlab 2013b. Using this function is easy and works as I expected:

s = sym('s');
latex((s+1)/3)

ans =

\frac{s}{3} + \frac{1}{3}

      

Than I have a simple matrix and latex function, return the following error:

A = [ 0 1 0; 1 -2 1; -2 4 -2];
latex(A)
Undefined function 'latex' for input arguments of type 'double'.

      

Another example:

latex(3/4 + 4)
Undefined function 'latex' for input arguments of type 'double'.

      

Works with symbolic variables, but does not work with integers. Where could the problem be?

+3


source to share


1 answer


From the documentation: LaTeX Representation of Symbolic Expression

Do:



latex(sym(A))
latex(sym(3/4+4)) % But this will return the result of the numbers, so \frac{19}{4}

      

+5


source







All Articles