23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Warning Control<br />

3 When you are ready to run your programs, use the <strong>MATLAB</strong> warning<br />

control statements to exercise the desired controls on all or selected<br />

warnings. Include message identifiers in these control statements when<br />

selecting specific warnings to act upon.<br />

Warning Statements<br />

The warning statements that you put into your M-file code must contain the<br />

string that is to be displayed when the warning is incurred, and may also<br />

contain a message identifier. If you are not planning to use warning control or<br />

if you have no need to single out certain warnings for control, then you need<br />

to specify the message string only. Use the syntax shown in the section on<br />

“Warnings” on page 8-14. Valid formats are<br />

warning('warnmsg')<br />

warning('formatted_warnmsg', arg1, arg2, ...)<br />

Attaching an Identifier to the Warning Statement<br />

Iftherearespecificwarningsthatyouwant<strong>MATLAB</strong>tobeabletoapply<br />

control statements to, then you need to include a message identifier in the<br />

warning statement. The message identifier must be the first argument in the<br />

statement. Valid formats are<br />

warning('msg_id', 'warnmsg')<br />

warning('msg_id', 'formatted_warnmsg', arg1, arg2, ...)<br />

See “Message Identifiers” on page 8-10 for information on how to specify the<br />

msg_id argument.<br />

Note When you specify more than one input argument with warning,<br />

<strong>MATLAB</strong> treats the warnmsg string as if it were a formatted_warnmsg. This<br />

is explained in “Formatted String Conversion” on page 8-5.<br />

Warning Control Statements<br />

Once you have the warning statements in your M-file code and are ready to<br />

executethecode,youcanindicatehowyouwant<strong>MATLAB</strong>toactonthese<br />

8-17

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

Saved successfully!

Ooh no, something went wrong!