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 />

Warning Control<br />

This section covers<br />

• “Warning Statements” on page 8-17<br />

• “Warning Control Statements” on page 8-17<br />

• “Output from Control Statements” on page 8-19<br />

• “Saving and Restoring State” on page 8-22<br />

• “Backtrace and Verbose Modes” on page 8-23<br />

<strong>MATLAB</strong> gives you the ability to control what happens when a warning is<br />

encountered during M-file program execution. Options that are available<br />

include<br />

• Display selected warnings<br />

• Ignore selected warnings<br />

• Stop in the debugger when a warning is invoked<br />

• Display an M-stack trace after a warning is invoked<br />

Depending on how you set up your warning controls, you can have these<br />

actions affect all warnings in your code, specific warnings that you select, or<br />

just the most recently invoked warning.<br />

Setting up this system of warning control involves several steps.<br />

1 Start by determining the scope of the control you will need for the warnings<br />

generated by your code. Do you want the above control operations to affect<br />

all the warnings in your code at once, or do you want to be able to control<br />

certain warnings separately?<br />

2 If the latter is true, you will need to identify those warnings you want to<br />

selectively control. This requires going through your code and attaching<br />

unique message identifiers to those warnings. If, on the other hand,<br />

you don’t require that fine a granularity of control, then the warning<br />

statements in your code need no message identifiers.<br />

8-16

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

Saved successfully!

Ooh no, something went wrong!