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

Infinity and NaN Functions<br />

See Infinity and NaN Functions on page 2-31 for a list of functions most<br />

commonly used with inf and NaN in <strong>MATLAB</strong>.<br />

Identifying Numeric Types<br />

You can check the data type of a variable x using any of these commands.<br />

Command<br />

Operation<br />

whos x Display the data type of x.<br />

xType = class(x);<br />

isnumeric(x)<br />

isa(x, 'integer')<br />

isa(x, 'uint64')<br />

isa(x, 'float')<br />

isa(x, 'double')<br />

isa(x, 'single')<br />

isreal(x)<br />

isnan(x)<br />

isinf(x)<br />

isfinite(x)<br />

Assignthedatatypeofx to a variable.<br />

Determine if x is a numeric type.<br />

Determine if x is the specified numeric type.<br />

(Examples for any integer, unsigned 64-bit integer,<br />

any floating point, double precision, and single<br />

precision are shown here).<br />

Determine if x is real or complex.<br />

Determine if x is Not a Number (NaN).<br />

Determine if x is infinite.<br />

Determine if x is finite.<br />

Display Format for Numeric Values<br />

By default, <strong>MATLAB</strong> displays numeric output as 5-digit scaled, fixed-point<br />

values. You can change the way numeric values are displayed to any of the<br />

following:<br />

• 5-digit scaled fixed point, floating point, or the best of the two<br />

• 15-digit scaled fixed point, floating point, or the best of the two<br />

• A ratio of small integers<br />

• Hexadecimal (base 16)<br />

• Bank notation<br />

2-27

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

Saved successfully!

Ooh no, something went wrong!