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
help you produce code that is more likely to be correct, understandable,
and maintainable. This white paper is a smaller, older, and less complete forerunner of the book.
- 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
Really helpful. everybody
should read something
like this before starting any coding ! (Now, it's my turn to
review everything that I did)
This pdf file is easy understood and
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.
Clear, concise and
reasonable. Should be a lot of help to
me (and others). Thanks.
Concise and thorough
Useful, short document that
reminds one of all the
things they should already do, but probably don't.
An excellent collection,
great for beginning or intermediate Matlab coders.
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
and more maintainable MATLAB code.
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
MATLAB documentation gets better with every release, but there is still value in supplements.
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.
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.
MATLAB Table Fundamentals, (PDF)
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.
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.
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.
Working With NaN, (PDF)
MATLAB has a few stumbling blocks to watch out for.
Numerical Gotchas, (PDF)
Use a checklist to produce quality code.
Coding Checklist, (PDF)
Data Visualization Toolbox for MATLAB
and extending the analytical and graphical methods for data analysis
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.]
- Analysis using robust statistical methods.
- Graphical methods for data exploration.
- Diagnostics for fit and model evaluation.
Feedback on the toolbox:
Its great software thank
McEwan, University of Waikato
van der Hulst, Ingenieursbureau S.D. Kamminga BV
Very good work!
Bryan, The MathWorks, Inc.
Lord, The MathWorks, Inc.
Holmgren, San Francisco State University