File Exchange

image thumbnail

MATLAB Functional Programming Style Guidelines

version 1.3 (237 KB) by

An annotated presentation for MATLAB programming style guidelines

1 Download

Updated

View License

A presentation based on a similar document that was provided by Richard Johnson some years ago. It provides an annotated summary of the main best practice guidelines for writing MATLAB programs.

Comments and Ratings (19)

That's a questionable naming style guide. It has nothing to do with functional programming

Alex

Alex (view profile)

Please look up the definition of Functional Programming. This has nothing to do with functional programming.

http://en.wikipedia.org/wiki/Functional_programming

Friedrich

Thank you very much!

Derek,

Thanks for the hint! I have inserted a disclaimer accordingly.

BR,
Fayssal

Fayssal,

You should put on the first slide:

This is a re-formatted version of
Richard Johnson's "MATLAB Programming Style Guidelines"

Acknowledging Johnson in the description above is not good enough because the description is not part of the document.

Thanks Daniel for the hint! It should be rectified now.

FYI, there's a typo on page 11, 'recommanded' instead of 'recommended'.

Mo Chen

Mo Chen (view profile)

The title is very misleading. "Functional style" actually means something like lisp, haskell and OCaml, not how to define your functions.

Yes there will be!

Chethan S

The file name indicates 'part1'. So will there be a part2 for this submission?

I have already read the article from Loren. Congratulations for putting this book together!

Richard Johnson

Richard Johnson (view profile)

The book that grew out of these guidelines was recently reviewed by Loren in her Art of MATLAB blog.
http://blogs.mathworks.com/loren/2011/02/10/book-review-the-elements-of-matlab-style/

Pi Ting

Thanks a lot!

It's true! And this is stated in the description of the submission. A link to the original document is also included in the references list of the presentation. I submitted this presentation because it is more visually appealing, and it is much lighter to digest than the original document. Does it matter at all? The goal here is that people find these guidelines and adapt them to their programming practices. I also don't see the legend you are talking about, since these are commonly used guidelines in other languages like Java and C++. However, Richard Johnson did a very good job in putting these guidelines together for MATLAB. If you are interested, he even has now published a book on the subject: http://www.amazon.com/Elements-MATLAB-Style-Richard-Johnson/dp/0521732581/ref=sr_1_2?ie=UTF8&s=books&qid=1297535830&sr=1-2

By the way, this presentation is not PowerPoint. It is a Lyx beamer-based presentation.

Michelle Hirsch

This appears to be a nearly direct copy of Richard Johnson's legendary MATLAB Programming Style Guidelines, just put into PowerPoint format.

http://www.mathworks.com/matlabcentral/fileexchange/2529-matlab-programming-style-guidelines

Do you mean regarding introducing logical variables for complex expressions? Of course, short circuiting can save carrying on extra tests. I did not mean to avoid the use of short circuiting completely. It is about breaking complex conditionals into smaller more readable variables that also explain the purpose of the conditionals. So, the goal is to reduce complexity and increase readability. Of course, it could be the case this will incurr extra tests that could be avoided due to short circuiting since we are evaluating all logical variables ahead of the test. In this case, one has to outweigh the gain in performance of using short circuiting vs. the gain in breaking the complexity of conditionals and improving readability.

Sean de

Sean de (view profile)

I disagree with your conditional preference. Since boolean operators can short circuit, some of the conditional calculations can be avoided.
http://matlab.wikia.com/wiki/FAQ#Do_boolean_operators_short-circuit.3F

Danny Sale

Danny Sale (view profile)

Thank you for uploading this. Great advice!

Updates

1.3

Name correction in the disclaimer

1.2

Addition of a disclaimer

1.1

Spelling errors corrected.

MATLAB Release
MATLAB 7.11 (R2010b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today