Poll
What is your main tool or approach for debugging MATLAB code?
18 Comments
disp('Got this far no29') works pretty well ;)
Joking aside, "Pause on Errors" has worked best for me - when it works. 9/10 times it does not trigger on an error for me. How do you guys get it to work?
I wonder what the "Other" methods are that people are using. The score in that category is higher than I expected.
The best one is the live script.
I have a simple 4-step approach that usually works.
- get so mad that steam comes out of my ears
- slam face on keyboard like a cartoon character
- roll around on the floor screaming obscenities
- troubleshoot the problem and fix it i guess
I hope that someone finds this helpful.
dbstop if error can help me locate the place the code bombs, but working backwards from there to locate the cause of the error is mostly breakpoints... and fprintf.
Some older releases don't automatically open the file and move the cursor if you use keyboard, so I use the line below on such releases. It works without incident (even on GNU Octave), as long as I never cd.
ans=dbstack;dbstop('in',strrep(mfilename,'.m',''),'at',num2str(ans(1).line+1)),drawnow %#ok<NOANS>