File Exchange Pick of the Week

Avoiding Coding Pitfalls 2

Posted by Brett Shoelson,

Whenever Loren Shure posts a new discussion about writing MATLAB code, anyone who wants to improve his or her technique should take notice. Loren may be the most MATLAB-savvy person I know, and is certainly my go-to person when I'm having difficulty understanding some MATLAB concept or implementation. This week, I would like to call attention to a new submission on the File Exchange to make sure that everyone knows it's there. Although the file was submitted by fellow MathWorker Linda Webb, it is actually a reprint of a News & Notes article that Loren wrote in 2008.

With concise examples, the article points out common pitfalls in MATLAB concerning: matrix and element-wise multiplication, transpose and conjugate transpose, using i or j as variables, command/function duality, and floating-point comparisons. Loren also provides some great tips on writing robust programs, with brief discussions of function handles, the use of "eval."

I encourage anyone who wants to learn from the master to download and read Loren's article. And make sure to subscribe to your favorite MathWorks newsletter, while you're at it. They're packed with pearls of wisdom!


Get the MATLAB code

Published with MATLAB® 7.7

2 CommentsOldest to Newest

Mea culpa…yes, indeed I did. Thanks, Steve, for pointing out my omission!

I certainly encourage everyone to link and subscribe to Loren’s blog, “Loren on the Art of MATLAB.” Steve’s hyperlink will take you there, or you can follow this URL:

http://blogs.mathworks.com/loren/

Cheers,
Brett

These postings are the author's and don't necessarily represent the opinions of MathWorks.