| MATLAB® | ![]() |
| On this page… |
|---|
There are many different classes of data that you can work with in the MATLAB® software. You can build matrices and arrays of floating-point and integer data, characters and strings, logical true and false states, etc. Two of the MATLAB classes, structures and cell arrays, provide a way to store dissimilar types of data in the same array. You can also develop your own classes.
There are 15 fundamental classes in MATLAB. Each of these classes is in the form of a matrix or array. This matrix or array is a minimum of 0-by-0 in size and can grow to an n-dimensional array of any size.
All of the fundamental classes are shown in lowercase, plain nonitalic text in the diagram below.

The two classes shown in italic text are user-defined, object-oriented user classes and Java classes. You can use the latter with the MATLAB interface to Sun™ Java™ (see Calling Sun™ Java™ Commands from MATLAB® Command Line in the MATLAB External Interfaces documentation).
You can create two-dimensional double and logical matrices using one of two storage formats: full or sparse. For matrices with mostly zero-valued elements, a sparse matrix requires a fraction of the storage space required for an equivalent full matrix. Sparse matrices invoke methods especially tailored to solve sparse problems
These classes require different amounts of storage, the smallest being a logical value or 8–bit integer which requires only 1 byte. It is important to keep this minimum size in mind if you work on data in files that were written using a precision smaller than 8 bits.
The following table describes these classes in more detail.
Class | Example | Description |
|---|---|---|
uint16(65000) | Array of signed (int) and unsigned (uint) integers. Some integer types require less storage space than single or double. All integer types except for int64 and uint64 can be used in mathematical operations. | |
single(3 * 10^38) | Array of single-precision numbers. Requires less storage space than double, but has less precision and a smaller range. | |
5 + 6i | Array of double-precision numbers. Two- dimensional arrays can be sparse. The default numeric type in MATLAB. | |
magic(4) > 10 | Array of logical values of 1 or 0 to represent true and false respectively. Two-dimensional arrays can be sparse. | |
'Hello' | Array of characters. Strings are represented as vectors of characters. For arrays containing more than one string, it is best to use cell arrays. | |
a{1,1} = 12; a{1,2} = 'Red'; a{1,3} = magic(4); | Array of indexed cells, each capable of storing an array of a different dimension and data type. | |
a.day = 12; a.color = 'Red'; a.mat = magic(3); | Array of C-like structures, each structure having named fields capable of storing an array of a different dimension and data type. | |
@sin | Pointer to a function. You can pass function handles to other functions. | |
polynom([0 -2 -5]) | Objects constructed from a user-defined class. See MATLAB® Classes | |
java.awt.Frame | Objects constructed from a Java class. See Sun™ Java™ Classes. |
![]() | Built-In Classes (Data Types) | Numeric Classes | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |