File Exchange

image thumbnail

MATLAB Style Guidelines 2.0

version (595 KB) by Richard Johnson
An updated guide to preferred coding style.


Updated 27 Mar 2014

View License

MATLAB has changed just a little in the 12 years since I wrote my previous style guide. This is an updated and revised version.
This document is concerned with correctness, clarity and generality. The goal of these guidelines is to help produce code that is more likely to be correct, understandable, sharable and maintainable.
These MATLAB coding recommendations are consistent with best practices in the software development community. The guidelines are generally the same as those for C, C++ and Java, with modifications for MATLAB features and history. The recommendations are based on guidelines for other languages collected from a number of sources and on personal experience.

Comments and Ratings (27)

Great recommendations, I find myself understanding my own code better!


Julian Hapke

I'd be so happy, if everybody who sends me code, would stick to those simple conventions.

Many thanks

Jiang WANG

Thank you so much for your sharing and efforts since 2003.

David Zhang

Tom Clark

Really good style guide, which is almost identical to the guide we developed internally and independently over many years in-house; we've collapsed onto this guide with minimal effort.

I left off the fifth star for two reasons:

1 - There's no specific naming conventions for classes, as well as class properties and methods. To be fair, TMW's examples of this have varied somewhat in style over the years.

2 - No original text file used to generate the PDF.

@Richard, if you'd like to put this up on GitHub with the base text file, I'd be very happy to collaborate on the class naming?

Very good idea!


Thanks, very useful.

@Richard: This is great stuff. Is it permissable to post this on an internal corporate website for a team to be shared ?

Igor Kuklin

No information on proper style of naming of classes (lowercase? camelConvention?) and properties. The .pdf seems to be formatted for very small screens, requires a lot of vertical scrolling vs version 1.5.

Ping Pei

very good

best way to prevent mistakes is having a strong style guide - Thanks!



Excellent style guidelines for MATLAB programming.

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux