Specializing in data analysis and visualization with MATLAB

Training Courses
Software Development
Contact Us

The Elements of MATLAB Style

This is the only book devoted to MATLAB style and best practices, focusing on how MATLAB code can be written to maximize its effectiveness.

Key Elements

  • Formatting
  • Naming
  • Documentation
  • Programming
  • Testing

MATLAB Programming Style Guidelines

Advice on writing MATLAB code usually addresses efficiency concerns, with recommendations such as "Don't use loops." This document is different. Its concerns are correctness and clarity. The goal of these guidelines is to help you produce code that is more likely to be correct, understandable, sharable and maintainable. This white paper is a smaller, older, and less complete forerunner of the book.

Key Elements

  • Naming conventions
  • Language usage
  • Layout and comments

Download MATLAB Style Guidelines (Revised V2), (PDF)

Feedback on the guidelines:

I thought this document encapsulated a boat load of good advice relevant for many programming languages, and included some nice MATLAB specific hints.
_ Penny Anderson

Really helpful. everybody should read something like this before starting any coding ! (Now, it's my turn to review everything that I did)
_ Frederic Bosche

This pdf file is easy understood and it's especially useful for MATLAB experienced programmers. The guidelines helped me to construct a more standardized, easy-maintained programs. No matter what kind of language you are using, there will be some concepts you can refer to.
_ Fu-Sung Wang

Clear, concise and reasonable. Should be a lot of help to me (and others). Thanks.
_ Richard Kirkeeide

Concise and thorough
_ William Zimmerman

Useful, short document that reminds one of all the things they should already do, but probably don't.
_ Mark Newton

An excellent collection, great for beginning or intermediate Matlab coders.
_ Michael Villalba

Great & Appreciated Guidelines! I hope I can follow all of them!
_ Fahad Al Mahmood

Very helpful. I typically write in MATLAB, and I haven't read about style guidelines before. This will help me write more readable and more maintainable MATLAB code.
_ B G

Great work. The document is well-written and spot-on. A much-needed addition to the MATLAB community.
_ Matthew Simoneau

Programming style guidelines for other languages are available here.

MATLAB Whitepapers

MATLAB documentation gets better with every release, but there is still value in supplements.

Data containers

The choice of the type of data container (arrays and objects) to use can have a big impact on your code. This paper discusses the options and provides examples of their use.

Download MATLAB Data Containers, (PDF)


The table is a class introduced in R2013b that is very useful for working with data. These papers discuss table features and provide examples of their use.

Download MATLAB Table Fundamentals, (PDF)

Download MATLAB Table Programming, (PDF)

MATLAB Source Control

Source control using Git was integrated into MATLAB starting with R2014b. The MATLAB documentation is probably fine after you have mastered it. Meanwhile here is a tutorial to get you started.

Download MATLAB Source Control With Git, (PDF)

Test Driven Development

Test-Driven Development is a core agile development practice that can help produce better code. This paper discusses the use of TDD with MATLAB.

Download MATLAB and TDD, (PDF)

Working With NaN

MATLAB uses NaN for several purposes. This paper discusses the roles of NaN and how to work with them.

Download Working With NaN, (PDF)

Numerical Gotchas

MATLAB has a few stumbling blocks to watch out for.

Download Numerical Gotchas, (PDF)

Coding Checklist

Use a checklist to produce quality code.

Download Coding Checklist, (PDF)

Data Visualization Toolbox for MATLAB

MATLAB EnabledMATLAB software implementing and extending the analytical and graphical methods for data analysis and visualization described in William S. Cleveland's book Visualizing Data. [This software was originally written in 1998. It runs correctly but may not follow current best practices.]

Key Benefits

  • Analysis using robust statistical methods.
  • Graphical methods for data exploration.
  • Diagnostics for fit and model evaluation.

Download the files.

Feedback on the toolbox:

Its great software thank you.
_James McEwan, University of Waikato

Great job.
_Lennard van der Hulst, Ingenieursbureau S.D. Kamminga BV

Very good work! Congratulations.
_Tom Bryan, The MathWorks, Inc.

Cool M-files
_Steve Lord, The MathWorks, Inc.

Magnificent job.
_Diego Holmgren, San Francisco State University