5.0

5.0 | 10 ratings Rate this file 162 downloads (last 30 days) File Size: 2.48 KB File ID: #2832

latex

by Tobin Driscoll

 

06 Dec 2002 (Updated 17 Dec 2002)

Code covered by BSD License  

Output a matrix in LaTeX format.

Download Now | 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 (10)
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

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Tobin Driscoll 22 Oct 2008 06:54:51
data export Tobin Driscoll 22 Oct 2008 06:54:51
latex Tobin Driscoll 22 Oct 2008 06:54:51
tex Tobin Driscoll 22 Oct 2008 06:54:51
prettyprint Tobin Driscoll 22 Oct 2008 06:54:51
utilities Tobin Driscoll 22 Oct 2008 06:54:51
import Tobin Driscoll 22 Oct 2008 06:54:51
export Tobin Driscoll 22 Oct 2008 06:54:51
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com