## How can I extract the time column of a timetable

### Antonio Melieni (view profile)

on 20 Apr 2019
Latest activity Commented on by Peter Perkins

on 3 May 2019

### Andrei Bobrov (view profile)

Hi,
I need to extrct the time column of a timetable as I need to manipulate it.
any Ideas?

David Wilson

### David Wilson (view profile)

on 20 Apr 2019
Look at the help file for timetable. You should be able to access the 1st column with the dot notation.
Following example is straight from the help file.
MeasurementTime = datetime({'2015-12-18 08:03:05';'2015-12-18 10:03:17';'2015-12-18 12:03:13'});
Temp = [37.3;39.1;42.3];
Pressure = [30.1;30.03;29.9];
WindSpeed = [13.4;6.5;7.3];
WindDirection = categorical({'NW';'N';'NW'});
TT = timetable(MeasurementTime,Temp,Pressure,WindSpeed,WindDirection)
Now reference as
>> TT.MeasurementTime
ans =
3×1 datetime array
18-Dec-2015 08:03:05
18-Dec-2015 10:03:17
18-Dec-2015 12:03:13
You could of course convert to a (normal) table, or even an array.
Antonio Melieni

### Antonio Melieni (view profile)

on 20 Apr 2019
what I needed was array.Time;
Peter Perkins

### Peter Perkins (view profile)

on 3 May 2019
Just for the record, David was correct, except for one subtle point: the row times in a timetable are metadata, not one of the variables. You can access them by name in exactly the same way, though.
David created his timetable with a workspace variable named MeasurementTime, whose name the timetable picked up; that's why his row times were named Measurement time. The default name is Time, though.

### Andrei Bobrov (view profile)

on 20 Apr 2019
Edited by Andrei Bobrov

### Andrei Bobrov (view profile)

on 20 Apr 2019

variant
a = rand(20,6);
date1 = datetime(2019,4,19) + hours(cumsum(70*rand(20,1)));
TT = array2timetable(a,'RowTimes',date1);
date_out = TT.Time;

Antonio Melieni

on 20 Apr 2019
thats it :)