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.

Warning Control<br />

Example 1 — Enabling a Selected Warning<br />

Enable just the actionNotTaken warning from Simulink by first turning off<br />

all warnings and then setting just that warning to on.<br />

warning off all<br />

warning on Simulink:actionNotTaken<br />

Next, use query to determine the current state of all warnings. It<br />

reports that you have set all warnings to off with the exception of<br />

Simulink:actionNotTaken.<br />

warning query all<br />

The default warning state is 'off'. Warnings not set to the<br />

default are<br />

State<br />

on<br />

Warning Identifier<br />

Simulink:actionNotTaken<br />

Example 2 — Disabling the Most Recent Warning<br />

Evaluating inv on zero displays a warning message. Turn off the most<br />

recently invoked warning with warning off last.<br />

inv(0)<br />

Warning: Matrix is singular to working precision.<br />

ans =<br />

Inf<br />

warning off last<br />

inv(0)<br />

ans =<br />

Inf<br />

% No warning is displayed this time<br />

Output from Control Statements<br />

The warning function, when used in a control statement, returns a <strong>MATLAB</strong><br />

structure array containing the previous state of the selected warning(s). Use<br />

the following syntax to return this information in structure array, s:<br />

s = warning('state', 'msg_id');<br />

8-19

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

Saved successfully!

Ooh no, something went wrong!