Showing posts with label matlab. Show all posts
Showing posts with label matlab. Show all posts

November 11, 2011

Bloody Debugging in Matlab and Perl

I'm no expert in neither Matlab nor Perl, but recently I've found out these useful commands, which I'm placing here for future reference:

In Matlab,
Instead of debugging using printing (bahh) or "keyboard()"-ing at the problematic line, simply execute 'dbstop if error' right after the matlab environment loads.
This will have a similar effect as keyboard(), but just after the line that crashed and before the program state is flushed - meaning, you will be able to inspect the code and the current state of variables, without having to run the code again.
see dbstop for more advance options

In Perl,
The Carp module  is handy when you want to debug your perl code.
I have no idea why die() and warn() don't have options that allow you to output the full stacktrace, but using say, Carp's confess() fuction you will get the full stacktrace.

Any other tips?
-- Tomer