matrix2latex

Conversion of MATLAB 2d array, into a LaTeX table.
41 Downloads
Aktualisiert 15. Feb 2024

Lizenz anzeigen

Modified matrix2latex, submitted by M. Koehler, to :
  • remove all warning
  • added an inputpaser instead of the IF and FOR loop and to add varargs
Usage:
matrix2latex(matrix, filename, varargs)
where
  • matrix is a 2 dimensional numerical
  • filename is a valid filename, in which the resulting latex code will be stored
  • varargs is one ore more of the following (denominator, value) combinations :
  1. 'rowLabels', array -> Can be used to label the rows of the resulting latex table
  2. 'columnLabels', array -> Can be used to label the columns of the resulting latex table
  3. 'alignment', 'value' -> Can be used to specify the alginment of the table within the latex document. Valid arguments are: 'l', 'c', and 'r' for left, center, and right, respectively
  4. 'format', 'value' -> Can be used to format the input data. 'value' has to be a valid format string, similar to the ones used in fprintf('format', value); the default value is '%-6.2f'.
  5. 'size', 'value' -> One of latex' recognized font-sizes, e.g. tiny, HUGE, Large, large, LARGE, etc.
  6. 'caption', 'value' -> caption of table on latex.
  7. 'version', 'value' -> value = 'normal' conserve all edges of the table ; value = 'light' delete all edges, except the lines around 'columnLabels' and at the end of the table. the default value is 'normal'.
Example input:
matrix = [1.5 1.764; 3.523 0.2];
rowLabels = {'row 1', 'row 2'};
columnLabels = {'col 1', 'col 2'};
% light version
matrix2latex(matrix, 'out.tex',...
'rowLabels', rowLabels,...
'columnLabels',columnLabels',...
'caption','My table', ...
'version','light');
% normal version
matrix2latex(matrix, 'out.tex',...
'rowLabels', rowLabels,...
'columnLabels',columnLabels',...
'caption','My table');
The resulting latex file can be included into any latex document by:
/input{out.tex}

Zitieren als

Marion Ranaivombola (2024). matrix2latex (https://www.mathworks.com/matlabcentral/fileexchange/107200-matrix2latex), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2021b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Quellenangaben

Inspiriert von: matrix2latex

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.4

edition of the function's name

1.0.3

minor correction about license

1.0.2

Minor correction of the text description

1.0.1

add of the input 'version' in order to conserve all edges of the table (version =normal) or to delete all edges, except the lines around 'columnLabels' and at the end of the table (version=light)

1.0.0