Code covered by the BSD License  

Highlights from
LaTeX table creation.

4.8 | 10 ratings Rate this file 24 Downloads (last 30 days) File Size: 4.59 KB File ID: #24387 Version: 1.0

LaTeX table creation.


Andrew (view profile)


Function for converting numeric or cell arrays to LaTeX table.

| Watch this File

File Information

This function was designed to be tool for converting MATLAB 2D arrays into a LaTeX tabular environment. It includes the ability to add horizontal and vertical labels, alter the data format, insert horizontal and vertical lines, as well as load and save settings.

Information regarding operate the function are contained in the comments, but here is a quick example:
>> latextable(rand(3,3),'Horiz',{'1','2','3'},'Hline',[0,1,NaN]);

I hope this function is useful for some people. I am sure there are probably a few bugs, so please let me know if you find any problems.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
05 Jun 2014 Rudy

Rudy (view profile)

02 Jun 2014 Kerry

Kerry (view profile)

Works neatly and as advertised.
One suggested option: return the LaTeX table string without saving to file. This is useful for including in the table in a matlab annotation, for example.
Note for anyone using the file output as the string in a matlab annotation: you may need to remove the newline characters first. For example,
worked for me.

09 Oct 2013 Daniel

Daniel (view profile)

It does exactly (and no more than) what you almost tried to implement on your own. Thanks!

18 Jan 2013 Sven

Sven (view profile)

Excellent submission. There are some improvements that would help the kind of person that uses latex/matlab (ie, people who like to automate things).

Please consider simply adding the table string as simply the output to the latextable() function. This would help people (like me) who don't actually want the whole preamble (the \begin{table} stuff with headers and the \end{table} part too).

For example, I've got some pretty complex header cells with merged cells that I can just hardcode in my document once, but I want to re-run my analysis and have the document update nicely. I don't expect MATLAB to handle the complex headering, but I would like it to just spit out the main table data, and I can get my latex file to import these contents _after_ the hard-coded header lines.

20 Sep 2011 Jud

Jud (view profile)

18 Jun 2010 Julien Emile-Geay

Very nice. Much better than matrix2latex.m, because the row and column labels actually work !

21 Apr 2010 Niklas

Niklas (view profile)

exactly what i was looking for. cheers!

07 Oct 2009 Tim Fairlow

Works well, thanks!

26 Sep 2009 Alan

Alan (view profile)

16 Sep 2009 Daniel

Daniel (view profile)

It is a pretty interesting function, but actually not what i was looking forward. I am trying to find a way to tipe in tex characters as headers of uitable (for GUI).

For example to be able to introduce greek characters as headers of columns and so on. I think that it is only possible to do this for figure right?

It would be awsome if anyone could give me a hand on that. And congratulations for the functions, i just wrote my Thesis with matlab and im sure it will help many other people.


Comment only
12 Jun 2009 Sener

Sener (view profile)

good job.. keep it up

Contact us