File Exchange Pick of the Week

June 27th, 2007

Algorithm development video

Here at the MathWorks, one of our Core Values is Continuous Improvement. Part of that is about being process oriented- “Clock building is better than time telling.”

Following that Core Value to talk about algorithm development, it takes more than just looking at finished algorithms (time telling), you need to look at the process of algorithm development (clock building). In that spirit, I wanted to present a new video where I spend fifteen minutes in MATLAB developing an algorithm. You will see every line of code as it is written (and rewritten). Along the way, you will see:

  • Short description of the algorithm to develop
  • Creation and exploration of a test case
  • Initial creation and reworking of the variable naming convention to avoid using “magic numbers”
  • Intermediate testing of algorithm
  • Keeping code clean and readable
  • Use of debugger to understand error messages
  • Use of visualization techniques to understand output
  • Effective use of MATLAB desktop tools

While the topic of the movie is an interesting little algorithm about fractals, the video is more about the process of programming in MATLAB.

Video Content

Find the files here.

6 Responses to “Algorithm development video”

  1. Brian Mintah replied on :

    Doug,
    Can you please post the video in another format, say Windows Media? I am unable to view the shock wave format and currently has new program install constraints on my PC.

    Thanks,
    Brian.

  2. Doug replied on :

    Brian,

    Sure thing. I just updated the zip file to include the .WMV you requested.

    Doug

  3. Andrew Catellier replied on :

    I find it re-assuring to be reminded that everyone has to start from scratch for some things, and that trials are endured by all.

    I do however, find it annoying that MATLAB error messages are still so very cryptic. We really shouldn’t have to enter debug mode to figure out why the subscripted dimension assignment was mismatched. Are we holding on to these messages for the sake of compatibility? Maybe a better message would be “expected matrix output not compatible with matrix element assignment”. Sure, that’s confusing too, but at least the person reading the error would see the red flag “matrix output” and recognize what he was doing.

    And while I’m on my soap box, can we have line numbers for errors thrown when running code in cell mode? How about printing values of loop control variables when errors are thrown from nested loops? I realize there are alternatives, and this may not be the best place to voice my concerns…just sayin’! Seems like these problems would greatly impact the productivity of many, if not all MATLAB users.

    Andrew

    [keyboard mishap edited as per Andrews note- Doug]

  4. Roy Goodman replied on :

    Doug,
    I’ve tried to view this with several different programs on my Powerbook. Each fails in its own way. Could please you post it on youtube as you have some earlier videos.
    Thanks,
    Roy

  5. Doug replied on :

    Roy,

    This was taken at a much higher resolution, it will not fit on YouTube. Sorry, this is the first report of not being able to view the video, anyone else seeing problems?

    Doug

  6. Doug replied on :

    I just changed the resolution and made it in-line. All should be well now.

    Enjoy,
    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • oleg: The author has implemented skewness, kurtosis and checks answering appropriately to the critic.
  • Ashok: how to store 10 or more random number in a loop a loop for i = 1:n mean(i) = input(’enter the mean value...
  • Ben: Doug, Thanks for the very helpful videos! Uitables seem like a convenient way to make a customized property...
  • oleg: Allstats has no checks, no comments and could also be improved (talking about prctile implementatio). Not to...
  • Todd: Additional information and a link to download free MATLAB and Simulink LEGO MINDSTORMS NXT code can be found at...
  • Doug: @Leo, Here is the “English version” of that code. “vec = []” makes an empty variable...
  • leo: Dear Doug I have a question in your code ‘October 9th, 2009 at 13:53′ vec = []; vec = [vec val]; I...
  • Shanker Keshavdas: You sir, are a gentleman and a scholar… No really, helped me out a lot. As to what is...
  • Quan Zheng: how can I get a copy of stepspecs.m?
  • Doug: @Lucy I think this is what you seek to move a line with the mouse in MATLAB. http://blogs.math...

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