Get LaTeX code for matrices in Matlab

34 views
Skip to first unread message

N. Karthikeyan

unread,
Apr 4, 2011, 2:22:44 PM4/4/11
to latex...@googlegroups.com
Hi,
Some of you know that Matlab has a command called 'latex()' which gives latex code when a symbolic expression is passed as input argument.

But we don't generally use symbolic variables  (at least I won't use), so how to get LaTeX code?

At least for matrices and variables I have found a way.

Suppose you have a 10x10 matrix stored in variable Y which could be the output matrix of your program. Now feeding this data in to LaTeX is not an easy task.

But you can use the following command

Y1=vpa(Y);  %variable precision arithmetic

The above command converts Y in to symbolic variable and stores in to Y1.
Now the command

latex(Y1)

gives you directly the LaTeX code for 10x10 matrix.

Just copy and paste that code in your tex file. You may have to do little formatting to get as per your requirements.

You may refer "Publishing M-Files" in Matlab help for knowing more about working with LaTeX in Matlab


Regards

karthick
Reply all
Reply to author
Forward
0 new messages