Documentation

array2timetable

Convert array to timetable

Syntax

TT = array2timetable(X,'RowTimes',rowTimes)
TT = array2timetable(X,'RowTimes',rowTimes,'VariableNames',{varName1,...,varNameN})

Description

example

TT= array2timetable(X,'RowTimes',rowTimes)convertsXandrowTimesto a timetable.Xis anM-by-Narray androwTimesis anM-by-1vector of datetime or duration values. Each column ofXbecomes a variable ofTT. The time values inrowTimeslabel the rows of the timetable.TTis anM-by-Ntimetable.

For more information on creating and using timetables, seeTimetables.

example

TT= array2timetable(X,'RowTimes',rowTimes,'VariableNames',{varName1,...,varNameN})assigns the namesvarName1,...,varNameNto the variables inTT. The variable names must be unique, valid MATLAB®identifiers in a cell array.

Examples

collapse all

Convert an array to a timetable. Add a vector of durations as the row times.

X = rand(5,3); Time = [seconds(1):seconds(1):seconds(5)]; TT = array2timetable(X,'RowTimes',Time)
TT=5x3 timetableTime X1 X2 X3 _____ _______ _______ _______ 1 sec 0.81472 0.09754 0.15761 2 sec 0.90579 0.2785 0.97059 3 sec 0.12699 0.54688 0.95717 4 sec 0.91338 0.95751 0.48538 5 sec 0.63236 0.96489 0.80028

Return the size of the timetable.TTcontains five rows and three variables. The set of row times is a table property. The row times are not contained in a table variable.

size(TT)
ans =5 3

Convert an array to a timetable. Specify the row times as a datetime vector. Specify names for the timetable variables.

X = randi([70 90],5,3); Time = datetime(2016,7,1:5); varNames = {'Temp1','Temp2',“Temp3”}; TT = array2timetable(X,'RowTimes',Time,'VariableNames',varNames)
TT=5x3 timetable时间Temp1 Temp2 Temp3  ___________ _____ _____ _____ 01-Jul-2016 87 72 73 02-Jul-2016 89 75 90 03-Jul-2016 72 81 90 04-Jul-2016 89 90 80 05-Jul-2016 83 90 86

Input Arguments

collapse all

Input matrix.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|logical|string|char|categorical|datetime|duration|calendarDuration
Complex Number Support:Yes

Output Arguments

collapse all

Output timetable. The timetable can store metadata such as descriptions, variable units, variable names, and row times. For more information, see the Properties section oftimetable.

Introduced in R2016b

Was this topic helpful?