Mathematics |
Introduction
MATLAB provides several data types that you can assign to numbers or numerical variables. By default, MATLAB assigns numbers the data type double
, which means that they are double-precision floating-point numbers that are 64 bits in length.
MATLAB performs operations on numbers of type double
using double-precision arithmetic. For most numerical purposes, double
is the recommended data type.
Besides double
, MATLAB also provides several other data types that require less memory than double
. These include
single
-- Single-precision floating-point numbers that are 32 bits in length
int8
and uint8
-- Signed and unsigned integers that are 8 bits in length
int16
and uint16
-- Signed and unsigned integers that are 16 bits in length
int32
and uint32
-- Signed and unsigned integers that are 32 bits in length
These data types are useful if you need to conserve memory, for example, if you are working with very large data sets such as image files. The following sections explain the issues you need to keep in mind when performing operations on nondouble data types:
single
.
Data Types in the MATLAB Programming documentation provides more information about these data types.
The following MATLAB functions return output of type single
or an integer data type when you call them with the optional input argument datatype
, which is a string containing one of data types listed above:
returns a 2-by-2 matrix of ones of type int8
.
In addition, the following functions return output of type single
when you call them with the input argument 'single'
:
See the reference pages for these functions for more information.
Nondouble Data Types | Integer Mathematics |
© 1994-2005 The MathWorks, Inc.