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.
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.
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
About
Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.
Could use ctrl+I for smart indent. I always forget about it myself.
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.
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