Code covered by the BSD License  

Highlights from
latex

5.0

5.0 | 13 ratings Rate this file 47 Downloads (last 30 days) File Size: 2.48 KB File ID: #2832

latex

by Toby Driscoll

 

06 Dec 2002 (Updated 17 Dec 2002)

Output a matrix in LaTeX format.

| Watch this File

File Information
Description

This file will output a MATLAB numeric matrix in a format suitable to paste into a LaTeX tabular environment. You can choose whether to individually cast each element in math mode (you wouldn't want to in the AMS bmatrix environment, for example). You can also choose a format specifier independently for each column of the matrix.

I find this useful to convert true matrices, convergence tables, and the like into a document-ready form. It's independent of the Symbolic Toolbox.

Examples:>> latex(toeplitz(1:4))
$1.0000$ & $2.0000$ & $3.0000$ & $4.0000$ \\
$2.0000$ & $1.0000$ & $2.0000$ & $3.0000$ \\
$3.0000$ & $2.0000$ & $1.0000$ & $2.0000$ \\
$4.0000$ & $3.0000$ & $2.0000$ & $1.0000$ \\

>> latex(toeplitz(1:4),'%i','nomath')
1 & 2 & 3 & 4 \\
2 & 1 & 2 & 3 \\
3 & 2 & 1 & 2 \\
4 & 3 & 2 & 1

>> latex(toeplitz(1:4),'%i','%.2f')
$1$ & $2.00$ & $3.00$ & $4.00$ \\
$2$ & $1.00$ & $2.00$ & $3.00$ \\
$3$ & $2.00$ & $1.00$ & $2.00$ \\
$4$ & $3.00$ & $2.00$ & $1.00$

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (13)
17 Mar 2003 Norbert Marwan

Works well - very nice programmed. Thanks a lot.

10 Feb 2004 c.l. fung

simple and intuitive. good work.

20 Oct 2005 Yves Blattmann

Nice, simple and effective.
Thanks to programmer...

07 Apr 2006 Javad Farzi

great.
I dont know if this code works with ratinal numbers or nut? for example, maybe somone want to generate a table with ratinal numbers to a book or other texts.

04 Apr 2007 Wolfgang Schwanghart

A very helpful tool. Thanks a lot.

31 Jan 2008 Craig Robinson

Worked perfectly for what I needed. I like the option of 'nomath' option.

07 Feb 2008 Paul Bendixen

Super tool!
This is really keeping it simple, thank you very much

02 Jul 2008 Simone Scaringi

WOW!!!! Thanks!

02 Jul 2008 Jas Ellis

Great, also deals with NaNs!

19 Jun 2009 Richard Crozier

Thnks, handy

01 Mar 2010 Oscar

I use it several times a week, brilliant piece of code. Thank you.

21 Mar 2010 Oskar Vivero  
10 Feb 2011 Dan Golding

This is really useful, thanks!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Toby Driscoll 22 Oct 2008 06:54:51
data export Toby Driscoll 22 Oct 2008 06:54:51
latex Toby Driscoll 22 Oct 2008 06:54:51
tex Toby Driscoll 22 Oct 2008 06:54:51
prettyprint Toby Driscoll 22 Oct 2008 06:54:51
export Toby Driscoll 22 Oct 2008 06:54:51
import Toby Driscoll 22 Oct 2008 06:54:51
utilities Toby Driscoll 22 Oct 2008 06:54:51
latex Dong Ye 22 Oct 2011 17:25:15
tex Fayez Shehab 28 Jan 2012 04:09:28

Contact us at files@mathworks.com