Arrays in tabular form whose named columns can have different types

table is a data type suitable for column-oriented or tabular data that is often stored as columns in a text file or in a spreadsheet. Tables consist of rows and column-oriented variables. Each variable in a table can have a different data type and a different size with the one restriction that each variable must have the same number of rows. For more information, see Create and Work with Tables or watch Tables and Categorical Arrays.


expand all

tableTable array with named variables that can contain different types
array2tableConvert homogeneous array to table
cell2tableConvert cell array to table
struct2tableConvert structure array to table
table2arrayConvert table to homogeneous array
table2cellConvert table to cell array
table2structConvert table to structure array
table2timetableConvert table to timetable
timetable2tableConvert timetable to table

Basic Import and Export

readtableCreate table from file
writetableWrite table to file

Define Import Rules

detectImportOptionsCreate import options based on file content
spreadsheetImportOptionsImport options object for Spreadsheets
getvaroptsGet variable import options
setvaroptsSet variable import options
setvartypeSet variable data types
previewPreview eight rows from file using import options
headGet top rows of table, timetable, or tall array
tailGet bottom rows of table, timetable, or tall array
summaryPrint summary of table, timetable, or categorical array
heightNumber of table rows
widthNumber of table variables
istableDetermine whether input is table
stackedplotStacked plot of several variables with common x-axis


sortrowsSort rows of matrix or table
uniqueUnique values in array
issortedrowsDetermine if matrix or table rows are sorted
topkrowsTop rows in sorted order

Rearrange Variables

addvarsAdd variables to table or timetable
renamevarsRename variables in table or timetable
movevarsMove variables in table or timetable
removevarsDelete variables from table or timetable
convertvarsConvert table or timetable variables to specified data type
splitvarsSplit multicolumn variables in table or timetable
mergevarsCombine table or timetable variables into multicolumn variable
vartypeSubscript into table or timetable by variable type


rows2varsReorient table or timetable so that rows become variables
stackStack data from multiple variables into single variable
unstackUnstack data from single variable into multiple variables
inner2outerInvert nested table-in-table hierarchy in tables or timetables

Customize Properties

addpropAdd custom properties to table or timetable
rmpropRemove custom properties from table or timetable

Join Using Key Variables

joinCombine two tables or timetables by rows using key variables
innerjoinInner join between two tables or timetables
outerjoinOuter join between two tables or timetables

Set Operations

unionSet union of two arrays
intersectSet intersection of two arrays
ismemberArray elements that are members of set array
setdiffSet difference of two arrays
setxorSet exclusive OR of two arrays
ismissingFind missing values
standardizeMissingInsert standard missing values
rmmissingRemove missing entries
fillmissingFill missing values
varfunApply function to table or timetable variables
rowfunApply function to table or timetable rows
findgroupsFind groups and return group numbers
splitapplySplit data into groups and apply function
groupsummaryGroup summary computations

Live Editor Tasks

Join TablesCombine two tables using key variables in the Live Editor
Stack Table VariablesCombine values from multiple table variables into one table variable in the Live Editor
Unstack Table VariablesDistribute values from one table variable to multiple table variables in the Live Editor


Advantages of Using Tables

Use tables to store mixed-type data conveniently, access data with numeric or named indexing, and to store metadata.

Create and Work with Tables

This example shows how to create a table from workspace variables, work with table data, and write tables to files for later use.

Access Data in Tables

Indexing into tables with parentheses, dot notation, and curly braces accesses table data in different ways. You can use indexing to create a table that is a subset of a larger table or to create an array from data in a table.

Calculations on Tables

This example shows how to perform calculation on tables.

Changes to DimensionNames Property in R2016b

Tables can raise compatibility warnings, and change dimension names, when you modify the DimensionNames property.