LaTeX and MATLAB

Powerful Math and Documentation Tools

MATLAB is a powerful calculation tool capable of very complex mathematics.  But, if you don't know how to use its features you will feel like you are just using a really complicated calculator.

LaTeX is a markdown language made for writing science and math documents.  It allows you to quickly and easily create pdf documents containing math formulae and calculations.  However, just jumping in can be overwhelming at first.

Browse through this page for tips and tricks that the tutors have come across for making efficient Matlab scripts and great looking Latex documents.

Where to get LaTeX

Latex is available for Windows, Mac, and Linux operating systems (and if you are wiling to work at it, you can get it on Android and ChromeOS).  

For WINDOWS: In windows you will need to install 2 parts:  the MikTex compiler that works in the background to build your document, and the latex editor of your choosing.  My favorite editor is TexMaker, but lots of people like to use Overleaf (an online latex editor).

MiKTeX (1st step for Windows install) - If you want to use a LaTeX editor in windows, you will have to install this MiKTeX package, which gives windows the ability to compile LaTeX code.  After this is installed, any LaTeX editor that you want to use will work.

TeXmaker - (available for Windows, Linux, and Mac)

A Latex editor that has loads of built in features and options to make getting started with Latex much easier, and complete customization once you get to know latex and want to add functionality or make your own menus.

Overleaf  - Online editor.  Overleaf is a user-friendly LaTeX editor that runs completely in your browser.  No installations needed on your computer.  Overleaf also allows you to share your projects (possibly with groupmates) so that you can collaborate in real time.


Where to get MATLAB or Octave

MATLAB is an expensive piece of software if you want to buy it on your own, however you are allowed to have an educational copy through the school.

Download MATLAB  through the MathWorks website and install.  To use Matlab you will need to create a MathWorks account,  be sure to use your student email address  so you will be able to access the full version of matlab under the school's license. 

OCTAVE is a free / opensource alternative to Matlab.  Octave runs using the most up-to-date python compilers, and is often more efficent with computer resources than Matlab.   Octave is also almost 100% compatible with the Matlab functions and scripts, so it is possible to move back and forth between the two programs with the same file. If Matlab runs slow or crashes your computer (or you are working on a project that requires you to have a non-educational version of software) give Octave a try.

Octave is available here: GNU Octave 


Inserting MatLab code into LaTeX 

This is an introduction to the MCODE package, a quick and easy way to drop MatLab code into your LaTeX document and have format and display like it does in the MatLab window.

Download the package through the link below, and unzip the archive.  Drop the mcode.sty file in the same folder as your .tex document, and then call it like it is a package:  \usepackage{mcode}  and you will have access to the mcode functions.


Inserting Excel Spreadsheets into LaTeX

So, you've already built your table in Excel to perform calculations.  It's formatted and labeled and even has borders around it.  Wouldn't it be nice if you could just cut and paste it straight into LaTeX (borders and all) and not have to rebuild the table in your report?

Excel2Latex is an Excel plugin that will take your selected table and output LaTeX code to cut and paste into your editor to create your formatted table in your report.

Excel2Latex can be downloaded from CTAN directly:

CTAN: Package Excel2Latex 

After downloading and installing the add-in here is a quick walkthrough of activating and using it:

tex.stackexchange: Installing and activating Excel2Latex add-in 

Introduction to MATLAB 

Here is very well put together tutorial introducing how to input code into matlab and some of the functions and things matlab can be used for.  This is from the EECS department and University of Michigan.   This file goes over many of the basic functions that students will use in Matlab, such as matrices, plots, figures, and importing data.  This tutorial assumes that you have an understanding of computer programming concepts and already have matlab installed on your computer.


The overleaf website is also a great place to find the LaTeX code for many mathematical expressions. On the right hand margin of this link you will find many categories of symbols and how they are coded.

https://www.overleaf.com/learn/latex/Mathematical_expressions 

How to use Overleaf (Group projects)

Once you have created an overleaf file, at the top right click 'Share'. In order to share this file with multiple groupmates you will want to turn on link sharing. This allows you to send your collaborators a link to the file, which then allows them to type on the file as well. Be sure to send them the link that reads 'Anyone with this link can edit this project.'