This repository contains a set of recommended MATLAB Coding Guidelines. These guidelines have been developed primarily for large organizations or teams of MATLAB developers who want to introduce some degree of regularity and consistency in their MATLAB code bases. Use of the guidelines is optional.
The guidelines contain Rules and Best Practices. Rules must be followed in order to comply with the guidelines. Rule violations are detected by the MATLAB Code Analyzer and identified in the MATLAB Editor and in the Code Analyzer report. Each version of the guidelines is accompanied by a codeAnalyzerConfiguration.json
file which contains the checks used by the Code Analyzer to detect Rule violations.
Best Practices are guidelines that contain recommendations for improving the quality of your MATLAB code. Following them is optional. Some Best Practices can (optionally) be detected as Rules by enabling a check in the Code Analyzer. The introductory material in the guidelines document explains Rules and Best Practices in more detail.
Each folder in this repo contains a version of the coding guidelines. Download the latest version of the guidelines that corresponds to your version of MATLAB as indicated in the following table.
Use guidelines version | With MATLAB version |
---|---|
Version 1.0 | R2025a and higher |
The contents of each folder is as follows.
- codeAnalyzerConfiguration.json
- MATLAB Coding Guidelines.md
- MATLAB Coding Guidelines.pdf
- RevisionHistory.txt
The guidelines are expected to evolve over time driven by feedback from the MATLAB community. We encourage your feedback and suggestions for future revisions. Feel free to open an issue or post to the discussions. Your insights and feedback help us improve this document and make it even more useful for the community.
You may use the guidelines document and the related codeAnalyzerConfiguration.json file as a starting point to create your own local guidelines to meet the specific needs of your organization.