## insert a matlab matrix into latex automatically

March 31st, 2006 by Lawrence David

manually writing out matlab matrices in latex is really tedious. here’s how to save yourself the time:

assume you have some matrix L

>> s = sym(L);

>> v = vpa(s,5); # assign numerical precision

>> latex(v)

matlab should now spit out the latex source code that you can directly copy into your .tex file.

on 24 Jun 2008 at 8:25 amSoumyaCould you help me in inserting a matrix within a line…all my efforts are producing the matrix in the next line. Thanks in advance.

on 26 Feb 2009 at 6:33 pmrambonitThanks, I didn’t know about this feature. Very useful.

on 19 Apr 2009 at 2:02 pmMatlab2Latex « wAnNaBe NeRd[...] http://desk.stinkpot.org:8080/tricks/index.php/2006/03/insert-a-matlab-matrix-into-latex-automatical… [...]

on 23 Nov 2009 at 12:24 pmMattVery helpful, thank you!!

on 26 Sep 2011 at 4:40 pmshunDoesn’t work perfectly for me on 2010a.

The output precision is the same.

vpa(A,3) : I have 0.333

but after latex(vpa(A,3))

I have 0.33333333333333

on 06 Oct 2011 at 6:22 pmStefanoTry this:

digits(4); //this changes the output precision

s=sym(A,’d'); //the ‘d’ flag makes sure the sym output is in decimal form

latex(s);

worked for me!

on 11 Jun 2020 at 7:00 amsuba subayou make blogging glance What host are you the use of? Can I am getting your associate link on your host? I desire my website loaded up as fast as yours lol

on 17 Jun 2020 at 9:27 amalquiler carros en medellinSimply wanna input that you have a very decent web site , I the layout it really stands out.

on 22 Jun 2020 at 7:22 amseptic tank pumpingUtterly indited content material, Really enjoyed studying.

on 06 Sep 2020 at 10:51 amaprender a apostarThis is one awesome blog.Really looking forward to read more.

on 20 Sep 2020 at 8:27 pmJoe Biden 2020 MerchandiseYou need to participate in a contest for the most effective blogs on the web. I will advocate this website!