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.

12 <strong>Programming</strong> Tips<br />

Setting Breakpoints from the Command Line<br />

You can set breakpoints with dbstop in any of the following ways:<br />

• Break at a specific M-file line number.<br />

• Break at the beginning of a specific subfunction.<br />

• BreakatthefirstexecutablelineinanM-file.<br />

• Break when a warning, or error, is generated.<br />

• Break if any infinite or NaN values are encountered.<br />

For more information: See Setting Breakpoints in the <strong>MATLAB</strong> Desktop<br />

Tools and Development Environment documentation.<br />

Finding Line Numbers to Set Breakpoints<br />

When debugging from the command line, a quick way to find line numbers for<br />

setting breakpoints is to use dbtype. Thedbtype function displays all or part<br />

of an M-file, also numbering each line. To display delaunay.m, use<br />

dbtype delaunay<br />

Todisplayonlylines35through41,use<br />

dbtype delaunay 35:41<br />

Stopping Execution on an Error or Warning<br />

Use dbstop if error to stop program execution on any error and enter<br />

debug mode. Use warning debug to stop execution on any warning and enter<br />

debug mode.<br />

For more information: See Debug, Backtrace, and Verbose Modes in the<br />

<strong>MATLAB</strong> <strong>Programming</strong> documentation.<br />

Locating an Error from the Error Message<br />

Click on the underlined text in an error message, and <strong>MATLAB</strong> opens the<br />

M-file being executed in its editor and places the cursor at the point of error.<br />

12-24

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

Saved successfully!

Ooh no, something went wrong!