Is there a document describing MATLAB coding standards or a good programming guide available?
96 views (last 30 days)
Show older comments
MathWorks Support Team
on 12 Oct 2012
Edited: MathWorks Support Team
on 25 Feb 2025
I am looking for documents that can help improve my MATLAB programming skill. I would be interested in any helpful online guides.
Accepted Answer
MathWorks Support Team
on 19 Feb 2025
Edited: MathWorks Support Team
on 25 Feb 2025
Coding Standards
MathWorks follows MonkeyProof Coding Standard for MATLAB since January 2022. This standard is maintained by a Change Control Board (CCB) and has been developed in collaboration with industry leaders and the TIOBE organization, which specializes in coding standards and code quality.
Best Practices for MATLAB Coding
You can refer to the MATLAB Code Analyzer Report, which helps in improving code through warning and error messages. For additional best practices in MATLAB coding, explore Loren on the Art of MATLAB.
To further enhance performance and memory usage in MATLAB scripts, consider reviewing these documentation pages:
For more help on specific functions or workflows, please check out our documentation Help Center and MATLAB Answers.
0 Comments
More Answers (1)
Co Melissant
on 5 Oct 2022
Edited: MathWorks Support Team
on 6 Dec 2024
Since January 2022 we have the MonkeyProof MATLAB Coding Standard, see https://doc.monkeyproofsolutions.nl/code-checker-for-matlab/monkeyproof-coding-standard-for-matlab/
This standard has a Change Control Board (CCB) and is written together with some industry-leaders and TIOBE https://www.tiobe.com, a company specialized in Coding Standards and Code Quality
5 Comments
Co Melissant
on 14 Apr 2023
There can be various reasons to go for char or for string to handle text, I mentioned a few as well. This is why CC4M can check on both. Also there is currently is no rule in the standard. But a rule is there to have exemptions on it :)
Stephen23
on 14 Apr 2023
Edited: Stephen23
on 14 Apr 2023
"I do not agree that character vectors should be considered deprecated."
I do not consider CHAR arrays as deprecated.
I do note that many users these days seems to expect text to be "atomic", perhaps due to experience with other programming languages and environments. SPRINTF et al processing arrays in memory-order produces countless threads on this forum... in contrast, overloaded PLUS (and COMPOSE, etc.) intuitively match what many users see and expect. For many common text tasks, it seems STRING is simpler.
It is also clear that the behavior of code can be very very different if users are not paying attention to these types and writing their code taking their differing properties into account:
I presumed that one point of an automated coding check is to warn for these kind of compatibility issues.
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!