Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Cleaner code in MATLAB part two 2

Posted by Doug Hull,

This second video in the cleaner code series talks about magic numbers, and how to avoid them. It also covers naming conventions for function names and binary variables. Use of subfunctions is also shown.

2 CommentsOldest to Newest

Martin Cohen replied on : 1 of 2
I long ago got in the habit of eliminating sqrt's from distance computations whenever possible, since the sqrt usually takes longer than computing the square of the distance. In this case, I would compare the sum of squares with r^2.
Doug replied on : 2 of 2
Martin, This is an excellent observation. I am thinking of adding another video in this series that might be able to fit in code optimizations like that. Thank you, Doug

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide