# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# 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)` converts `X` and `rowTimes` to a timetable. `X` is an `M`-by-`N` array and `rowTimes` is an `M`-by-`1` vector of datetime or duration values. Each column of `X` becomes a variable of `TT`. The time values in `rowTimes` label the rows of the timetable. `TT` is an `M`-by-`N` timetable.For more information on creating and using timetables, see Timetables.```

example

````TT = array2timetable(X,'RowTimes',rowTimes,'VariableNames',{varName1,...,varNameN})` assigns the names `varName1,...,varNameN` to the variables in `TT`. 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 timetable Time 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. `TT` contains 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 Time 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 of `timetable`.