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.

Numeric Types<br />

Turning Warnings On or Off Temporarily. When writing M-files that<br />

contain integer data types, it is sometimes convenient to temporarily turn<br />

integer warnings on, and then return the states of the warnings ('on' or<br />

'off') to their previous settings. The following commands illustrate how to<br />

do this:<br />

oldState = intwarning('on');<br />

int8(200);<br />

Warning: Out of range value converted to intmin('int8') or<br />

intmax('int8').<br />

intwarning(oldState)<br />

To temporarily turn the warnings off, change the first line of the preceding<br />

code to<br />

oldState = intwarning('off');<br />

Recommended Usage of Math Overflow Warning. Enabling the<br />

<strong>MATLAB</strong>:intMathOverflow warning slows down integer arithmetic. It is<br />

recommended that you enable this particular warning only when you need<br />

to diagnose unusual behavior in your code, and disable it during normal<br />

program operation. The other integer warnings listed above do not affect<br />

program performance.<br />

Note that calling intwarning('on') enables all four integer warnings,<br />

including the intMathOverflow warning that can have an effect on integer<br />

arithmetic.<br />

Integer Functions<br />

See Integer Functions on page 2-30 for a list of functions most commonly used<br />

with integers in <strong>MATLAB</strong>.<br />

2-13

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

Saved successfully!

Ooh no, something went wrong!