-->

Sunday, April 6, 2014

Debugging matlab from command line

dbstop in [m-file] 
This sets a breakpoint on the first executable line of the script or function [m-file]. The following command:

dbstop in why 

sets a breakpoint on the first line of why.m that can be executed. For why.m, this line is line 10.

dbstop  in [m-file] at [line number] This sets a breakpoint in the script or function [m-file] on line
number [line number]. For instance:

dbstop in why at 10

dbstep 

This will cause MATLAB to execute one line of code and remain in debug mode. There are also three alternate syntaxes for DBSTEP, which will allow you to do more than simply step through one line:

dbstep N

This will cause MATLAB to execute the next N lines, where N is a positive integer.

dbstep in 

If the next line to be executed is a call to another function, this syntax will cause the Editor/Debugger to open that function. MATLAB will stop at the first line in that function, as though there was a breakpoint at that line.

dbstep out

This syntax will cause MATLAB to execute the rest of the lines in the current function, then return to the calling function and stop on the line immediately after the function call.

No comments:

Post a Comment