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.

Debugging<br />

For more information: See Types of Errors in the <strong>MATLAB</strong> Desktop Tools<br />

and Development Environment documentation.<br />

Using Warnings to Help Debug<br />

You can detect erroneous or unexpectedbehaviorinyourprogramsby<br />

inserting warning messages that <strong>MATLAB</strong> will display under the conditions<br />

you specify. See the section on “Warning Control” on page 8-16 in the<br />

documentation to find out how to selectively enable warnings.<br />

For more information: See the warning function reference page.<br />

Making Code Execution Visible<br />

Aneasywaytoseetheendresultofaparticularlineofcodeistoeditthe<br />

program and temporarily remove the terminating semicolon from that line.<br />

Then, run your program and the evaluation of that statement is displayed<br />

on the screen.<br />

For more information: See Finding Errors in the <strong>MATLAB</strong> Desktop Tools<br />

and Development Environment documentation.<br />

Debugging Scripts<br />

Scripts store their variables in a workspace that is shared with the caller of<br />

the script. So, when you debug a script from the command line, the script uses<br />

variables from the base workspace. To avoid errors caused by workspace<br />

sharing, type clear all before starting to debug your script to clear the<br />

base workspace.<br />

12-25

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

Saved successfully!

Ooh no, something went wrong!