MATLAB Data Types
The basic data type (also called a class) in MATLAB is the array or matrix. There are 15 fundamental data types in MATLAB. Each of these data types is in the build of a matrix or array. This matrix or arrays are a minimum of 0by0 in size and can increase to an ndimensional array of any size.
The following table describes these data types are:
Data Type 
Example 
Description 
int8, uint8,
int16, uint16,
int32, uint32,
int64, uint64 
uint16(65000) 
The array of signed and unsigned integers. It requires less storage space than single or double. All integer data types except for int64 and uint64 can be used in mathematical operations. 
single 
3 * 10^38 
The array of singleprecision numbers. It requires less storage space than double but has less precision and a smaller range. 
double 
3 * 10^300
5 + 6i 
Array of doubleprecision numbers. Twodimensional array can be sparse. The default numeric types in MATLAB. 
logical 
magic(4) > 10 
Array of logical value of 1 or 0 to represent true and false respectively. Twodimensional arrays can be sparse. 
char 
'Hello' 
Array of characters. Strings are represented as vectors of characters. For arrays including more than one string, it is good to use cell arrays. 
cell array 
a{1,1} = 12;
a{1,2} = 'Red';
a{1,3} = magic(4); 
Array of indexed cells, each capable of saving an array of a various dimension and data type. 
structure 
a.day = 12;
a.color = 'Red';
a.mat = magic(3); 
Array of Clike structures, each structure having named fields capable of storing an array of a different dimension and data type. 
function handle 
@sin 
Pointer to a function. You can pass function handles to other functions. 
user class 
polynom([0 2 5]) 
Objects constructed from a userdefined class. 
Java class 
java.awt.Frame 
Objects constructed from a Java class. 
Numeric Types
Numeric data types in MATLAB contain signed and unsigned integers, and single and doubleprecision floatingpoint numbers. Integer and singleprecision array offer more memory efficient storage than doubleprecision.
All numeric types provide basic array functions, such as subscripting and reshaping. All numeric types except for int64 and uint64 can be used in numerical operations.
Integers
MATLAB has four signed and four unsigned integers data type.
Signed types enable to work with a negative integer as well as positive, but cannot perform as wide a range of number as the unsigned type because one bit is used to designate positive or negative signs for the number.
Unsigned types give a wider range of numbers, but these numbers can only be zero or positive.
MATLAB provides 1, 2, 4, and 8byte storage for numeric data. We can save memory and execution time for our programs if we use the smallest integer type that accommodates your data. For example, we don't need a 32bit integer to save the value 100.
Here are the eight numeric data type, the range of values can save with each type, and the MATLAB conversion operation required to create that type:
Data Type 
Range of Values 
Conversion Function 
Signed 8bit integer 
2^{7} to 2^{7}1 
int8 
Signed 16bit integer 
2^{15} to 2^{15}1 
int16 
Signed 32bit integer 
2^{31} to 2^{31}1 
int32 
Signed 64bit integer 
2^{63} to 2^{63}1 
int64 
Unsigned 8bit integer 
0 to 2^{8}1 
uint8 
Unsigned 16bit integer 
0 to 2^{16}1 
uint16 
Unsigned 32bit integer 
0 to 2^{32}1 
uint32 
Unsigned 64bit integer 
0 to 2^{64}1 
uint64 
Creating Integer Data
MATLAB save numeric data as a doubleprecision floatingpoint by default. To save data as an integer, use one of the conversion functions shown in the table above:
We can use the whos function to show the dimensions, byte count, and data type of an array represented by a variable:
We can use the class function if we want to assign the output as shown here:
Use the isinteger function if you just want to verify that x is an integer:
Integer Functions
Function 
Description 
int8, int16,
int32, int64 
It convert to signed 1, 2, 4, or 8byte integer. 
uint8, uint16,
uint32, uint64 
It converts to unsigned 1, 2, 4, or 8byte integer. 
class 
It returns the data type of an object. 
isa 
It determines if the input value has the specified data type. 
isinteger 
It determines if input value is an integer array. 
isnumeric 
It determines if the input value is a numeric array. 
FloatingPoint Numbers
MATLAB show floatingpoint numbers in either doubleprecision or singleprecision format. The default is doubleprecision, but we can make any number of singleprecision with a simple conversion function.
DoublePrecision Floating Point
MATLAB composes the double data type according to IEEE Standard 754 for double precision. Any value stored as a doubleneeded 64 bits, formatted as shown in the table below:
Bits 
Usage 
63
 Sign (0 = positive, 1 = negative)

62 to 52
 Exponent, biased by 1023

51 to 0
 Fraction f of the number 1.f

SinglePrecision Floating Point
MATLAB composes the single data type according to IEEE Standard 754 for single precision. Any value save as a single require 32 bits, formatted as shown in the table following:
Bits 
Usage 
31 
Sign (0 = positive, 1 = negative) 
30 to 23 
Exponent, biased by 127 
22 to 0 
Fraction f of the number 1.f 
FloatingPoint Functions
Function 
Description 
double 
It converts to double precision. 
single 
It converts to single precision. 
class 
It returns the data type of an object. 
isa 
It determines if the input value has the specified data type. 
isfloat 
It determines if the input value is a floatingpoint array. 
isnumeric 
It determines if the input value is a numeric array 
eps 
It returns the floatingpoint relative accuracy. This value is the tolerance MATLAB uses in its evaluation. 
realmax 
It returns the largest floatingpoint number your computer can represent. 
realmin 
It returns the smallest floatingpoint number our computer can represent. 
Complex Numbers
Complex numbers consist of two separate part: a real part and an imaginary part. The primary imaginary unit is equal to the square root of 1. This is display in MATLAB by either of two letters: i or j.
Creating Complex Numbers
The following statement shows one method of creating a complex value in MATLAB. The variable x is assigned a complex number with a real part of 2 and an imaginary part of 3:
x = 2 + 3i;
Complex Number Functions
Function 
Description 
complex 
It construct complex data from real and imaginary components. 
i or j 
It returns the imaginary unit used in constructing complex data. 
real 
It returns the real part of a complex number 
imag 
It returns the imaginary part of a complex number. 
isreal 
It determines if a number is real or imaginary. 
