23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8 Error Handling<br />

Debugging Errors and Warnings<br />

You can direct <strong>MATLAB</strong> to temporarily stop the execution of an M-file<br />

program in the event of a run-time error or warning, at the same time opening<br />

a debug window paused at the M-file line that generated the error or warning.<br />

This enables you to examine values internal to the program and determine<br />

the cause of the error.<br />

Use the dbstop function to have <strong>MATLAB</strong> stop execution and enter debug<br />

mode when any M-file you subsequently run produces a run-time error or<br />

warning. There are three types of such breakpoints that you can set.<br />

Command<br />

dbstop if all<br />

error<br />

dbstop if error<br />

dbstop if warning<br />

Description<br />

Stop on any error.<br />

Stop on any error not detected within a try-catch<br />

block.<br />

Stop on any warning.<br />

In all three cases, the M-file you are trying to debug must be in a directory<br />

that is on the search path or in the current directory.<br />

You cannot resume execution after an error; use dbquit to exit from the<br />

Debugger. Toresumeexecutionafterawarning,usedbcont or dbstep.<br />

8-26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!