matrix2latex

MATLAB array to LaTeX table converter.
23,9K Downloads
Aktualisiert 17. Mai 2004

Lizenz anzeigen

This function converts an MATLAB 2-dimensional array (matrix) which can be numerical or a cell array, into proper formated LaTeX code. The result will be a file that can be included into any LaTeX document, and will display the data through the 'tabular' environment.

% Usage:
% matrix2late(matrix, filename, varargs)
% where
% - matrix is a 2 dimensional numerical or cell array
% - 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
% + 'rowLabels', array -> Can be used to label the rows of the
% resulting latex table
% + 'columnLabels', array -> Can be used to label the columns of the
% resulting latex table
% + '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
% + '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);
% + 'size', 'value' -> One of latex' recognized font-sizes, e.g. tiny,
% HUGE, Large, large, LARGE, etc.
%
% Example input:
% matrix = [1.5 1.764; 3.523 0.2];
% rowLabels = {'row 1', 'row 2'};
% columnLabels = {'col 1', 'col 2'};
% matrix2latex(matrix, 'out.tex', 'rowLabels', rowLabels, 'columnLabels', columnLabels, 'alignment', 'c', 'format', '%-6.2f', 'size', 'tiny');
%
% The resulting latex file can be included into any latex document by:
% /input{out.tex}
%
% Enjoy life!!!

Zitieren als

Moritz Koehler (2024). matrix2latex (https://www.mathworks.com/matlabcentral/fileexchange/4894-matrix2latex), MATLAB Central File Exchange. Abgerufen .

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

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.0.0

Update to v 1.1

-> Supports now LaTeX font sizes