Doug’s MATLAB Video Tutorials

December 12th, 2008

Video Tutorial: Using visualization to debug

A question came up on the MATLAB newsgroup about debugging a sorting algorithm. I thought this was an excellent opportunity to show how visualization of intermediate results would help to determine why an algorithm does not work as hoped. This technique of adding intermediate plots as a means of debugging is important to MATLAB programming. Because such visualization is easy, you should use it to make sure you understand your algorithm.
The original thread with the question is here.

3 Responses to “Video Tutorial: Using visualization to debug”

  1. Adam replied on :

    Could use ctrl+I for smart indent. I always forget about it myself.

  2. xapu_k replied on :

    I’m not so sure that this type of “visual debug” is very effective. I think working with the matlab debugger is way much faster. If one is a command-line zealot, functions like keyboard and dbstop are a great way to debug. Loren has posted some stuff on this topic on her blog.

  3. dhull replied on :

    Xapu,

    As is often the case with my videos, I am trying to show a concept that is useful for bigger problems. This technique is complete overkill for a problem of this size, but would be essential for more complicated algorithms.

    -Thanks for watching,
    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).


Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

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