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.

2 Data Types<br />

Numeric Types<br />

Numeric data types in <strong>MATLAB</strong> include signed and unsigned integers, and<br />

single- and double-precision floating-point numbers. By default, <strong>MATLAB</strong><br />

stores all numeric values as double-precision floating point. However,<br />

you can choose to store any number, or array of numbers, as integers<br />

or as single-precision. Integer and single-precision arrays offer more<br />

memory-efficient storage than double-precision.<br />

All numeric types support basic array operations, such as subscripting and<br />

reshaping. All numeric types except for int64 and uint64 can be used in<br />

mathematical operations.<br />

This section covers the following topics:<br />

• “Integers” on page 2-6<br />

• “Floating-Point Numbers” on page 2-14<br />

• “Complex Numbers” on page 2-24<br />

• “Infinity and NaN” on page 2-25<br />

• “Identifying Numeric Types” on page 2-27<br />

• “Display Format for Numeric Values” on page 2-27<br />

• “Function Summary” on page 2-29<br />

Integers<br />

<strong>MATLAB</strong> has four signed and four unsigned integer data types. Signed types<br />

enable you to work with negative integers as well as positive, but cannot<br />

represent as wide a range of numbers as the unsigned types because one bit<br />

is used to designate a positive or negative sign for the number. Unsigned<br />

types give you a wider range of numbers, but these numbers can only be<br />

zero or positive.<br />

This section covers:<br />

• “Creating Integer Data” on page 2-7<br />

• “Arithmetic Operations on Integer Data Types” on page 2-9<br />

2-6

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

Saved successfully!

Ooh no, something went wrong!