Programming and Data Types    

Debugging Errors and Warnings

You can direct MATLAB to temporarily stop the execution of an M-file program in the event of a run-time error or warning, at the same time opening a debug window paused at the M-file line that generated the error or warning. This enables you to examine values internal to the program and determine the cause of the error.

Use the dbstop function to have MATLAB stop execution and enter debug mode when any M-file you subsequently run produces a run-time error or warning. There are three types of such breakpoints that you can set.

Command
Description
dbstop if all error
Stop on any error
dbstop if error
Stop on any error not detected within a try-catch block
dbstop if warning
Stop on any warning

In all three cases, the M-file you are trying to debug must be in a directory that is on the search path or in the current directory.

You cannot resume execution after an error; use dbquit to exit from the Debugger. Use dbcont or dbstep to resume execution after a warning.


  Warning Control Shell Escape Functions