MATLAB Programming Style Guidelines
Richard Johnson
Version 1.5 October 2002
Copyright © 2002 Datatool
“Language is like a cracked kettle on which we beat tunes to dance to, while all the time
we long to move the stars to pity.” Gustave Flaubert, in Madame Bovary
Table of Contents
Introduction.............................................................................................................................................. 2
Naming Conventions ............................................................................................................................. 2
Variables.............................................................................................................................................. 2
Constants.............................................................................................................................................4
Structures ............................................................................................................................................ 4
Functions ............................................................................................................................................. 4
General ................................................................................................................................................ 6
Files and Organization........................................................................................................................... 6
M Files.................................................................................................................................................. 6
Input and Output................................................................................................................................. 7
Statements .............................................................................................................................................. 7
Variables.............................................................................................................................................. 7
Loops.................................................................................................................................................... 8
Conditionals.........................................................................................................................................8
General ................................................................................................................................................ 9
Layout, Comments and Documentation ........................................................................................... 10
Layout ................................................................................................................................................ 10
White Space...................................................................................................................................... 11
Comments ......................................................................................................................................... 12
Documentation.................................................................................................................................. 13
References ............................................................................................................................................ 13