Code Monkey home page Code Monkey logo

tbl2latex's Introduction

tbl2latex

About

A MATLAB function that reads content from an Excel file and converts it to LaTeX table code or converts a MATLAB table or cell array into LaTeX table code. LaTeX table code is referring to column entries separated by & and rows ended with \\

Read from Excel file

tbl2latex(filename)
Read the contents of the Excel file filename and convert it to LaTeX table code.

tbl2latex(filename,sheet)
Read the contents of the Excel file filename on sheet sheet and convert it to LaTeX table code.

tbl2latex(filename,sheet,range)
Read the contents of the Excel file filename on sheet sheet in range range and convert it to LaTeX table code.

tbl2latex(filename, sheet, range, dcl)
dcl = A vector containing the the desired number of decimals for every column from left to right that contains numerical values.
The default value is 2 decimals.

tbl2latex(filename, sheet, range, dcl, type)
type = A vector of characters containing the desired formatting of the numerical values for every column from left to right
using the formatSpec from the sprintf function. The default value is 'f'.
See further in the documentation for sprintf.

Example

tbl2latex('mytable.xlsx','tables', 'A1:C3', [3, 2], ['f','e']) Read the content in file mytable.xlsx on sheet tables in range A1:C3 where the first column with numerical values will be rounded to 3 decimals and the second one rounded to 2 decimals. The first column will be displayed as a float and the second column in exponential form.

Contents of the Excel file <mytable.xlsx>

   A       B        C       D
 1 Type    U-value  Cost    g-value
 2 Window  0,953    6500    0,5
 3 Wall    0,16     8425,5
 4 Roof    0,10     7425

Output from tbl2latex

 Type     &  U-value   &      Cost  \\
 Window   &    0.953   &  6.50e+03  \\
 Wall     &    0.160   &  8.43e+03  \\

Convert existing MATLAB table or cell array

tbl2latex(tbl)
Converts the contents of tbl to LaTeX table code. tbl can be a MATLAB table or cell array.

tbl2latex(tbl, dcl)
dcl = A vector containing the the desired number of decimals for every column from left to right that contains numerical values.
The default value is 2 decimals.

tbl2latex(tbl, dcl, type)
type = A vector of characters containing the desired formatting of the numerical values for every column from left to right
using the formatSpec from the sprintf function.
The default value is 'f'.
See further in the documentation for sprintf.

Foreign Characters

The default character encoding for MATLAB on Windows is usually windows-1252. tbl2latex.m is written in UTF-8.
This will cause characters such as å, ä, ö not to display correctly.

The character encoding for your system can be shown by running the command slCharacterEncoding in the MATLAB terminal.
To change the character encoding to UTF-8 run the command slCharacterEncoding('UTF-8').

Function History

Version : 1.01
Last updated : 2018-03-18 by Anton Lydell

This function (version 1.0) was originally created by:
Anton Lydell
Student M.Sc., Energy and Environmental Technology
Linköping University
2018-02-25
LinkedIn

tbl2latex's People

Contributors

antonlydell avatar

Stargazers

 avatar  avatar Adnan Avdagic avatar

Watchers

Adnan Avdagic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.