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.

Numeric Types<br />

Complex Number Functions<br />

See Complex Number Functions on page 2-31 for a list of functions most<br />

commonly used with <strong>MATLAB</strong> complex numbers in <strong>MATLAB</strong>.<br />

Infinity and NaN<br />

<strong>MATLAB</strong> uses the special values inf, -inf, andNaN to represent values that<br />

are positive and negative infinity, and not a number respectively.<br />

Infinity<br />

<strong>MATLAB</strong> represents infinity by the special value inf. Infinity results from<br />

operations like division by zero and overflow, which lead to results too large<br />

to represent as conventional floating-point values. <strong>MATLAB</strong> also provides<br />

afunctioncalledinf that returns the IEEE arithmetic representation for<br />

positive infinity as a double scalar value.<br />

Several examples of statements that return positive or negative infinity in<br />

<strong>MATLAB</strong> are shown here.<br />

x = 1/0<br />

x =<br />

Inf<br />

x = exp(1000)<br />

x =<br />

Inf<br />

x = 1.e1000<br />

x =<br />

Inf<br />

x = log(0)<br />

x =<br />

-Inf<br />

Use the isinf function to verify that x is positive or negative infinity:<br />

x = log(0);<br />

isinf(x)<br />

ans =<br />

1<br />

2-25

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

Saved successfully!

Ooh no, something went wrong!