MATLAB Classes

There are many different data types, or classes, that you can work with in the MATLAB® software. You can build matrices and arrays of floating-point and integer data, characters and strings, and logical true and false states. Function handles connect your code with any MATLAB function regardless of the current scope. Tables, structures, and cell arrays provide a way to store dissimilar types of data in the same container.

There are 16 fundamental classes in MATLAB. Each of these classes is in the form of a matrix or array. With the exception of function handles, this matrix or array is a minimum of 0-by-0 in size and can grow to an n-dimensional array of any size.
The following table describes the fundamental classes in more detail.

Class Name Documentation Intended Use
double, single Floating-Point Numbers
  • Required for fractional numeric data.

  • Double and Single precision.

  • Use realmin and realmax to show range of values.

  • Two-dimensional arrays can be sparse.

  • Default numeric type in MATLAB.

int8, uint8, 
int16, uint16,
int32, uint32,
int64, uint64
  • Use for signed and unsigned whole numbers.

  • More efficient use of memory.

  • Use intmin and intmax to show range of values.

  • Choose from 4 sizes (8, 16, 32, and 64 bits).

char Characters and Strings
  • Data type for text.

  • Native or Unicode.

  • Converts to/from numeric.

  • Use with regular expressions.

  • For multiple strings, use cell arrays.

logical Logical Operations
  • Use in relational conditions or to test state.

  • Can have one of two values: true or false.

  • Also useful in array indexing.

  • Two-dimensional arrays can be sparse.

function_handle Function Handles
  • Pointer to a function.

  • Enables passing a function to another function

  • Can also call functions outside usual scope.

  • Useful in Handle Graphics callbacks.

  • Save to MAT-file and restore later.

table Tables
  • Rectangular container for mixed-type, column-oriented data.

  • Row and variable names identify contents.

  • Use Table Properties to store metadata such as variable units.

  • Manipulation of elements similar to numeric or logical arrays.

  • Access data by numeric or named index.

  • Can select a subset of data and preserve the table container or can extract the data from a table.

struct Structures
  • Fields store arrays of varying classes and sizes.

  • Access one or all fields/indices in single operation.

  • Field names identify contents.

  • Method of passing function arguments.

  • Use in comma-separated lists.

  • More memory required for overhead

cell Cell Arrays
  • Cells store arrays of varying classes and sizes.

  • Allows freedom to package data as you want.

  • Manipulation of elements is similar to numeric or logical arrays.

  • Method of passing function arguments.

  • Use in comma-separated lists.

  • More memory required for overhead


You may also like...