How can I extract the time column of a timetable

121 vues (au cours des 30 derniers jours)
Antonio Melieni
Antonio Melieni le 20 Avr 2019
Commenté : Ali Afruzi le 1 Avr 2022
Hi,
I need to extrct the time column of a timetable as I need to manipulate it.
any Ideas?
  3 commentaires
Antonio Melieni
Antonio Melieni le 20 Avr 2019
what I needed was array.Time;
Peter Perkins
Peter Perkins le 3 Mai 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.

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 20 Avr 2019
Modifié(e) : Andrei Bobrov le 20 Avr 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;
  2 commentaires
Antonio Melieni
Antonio Melieni le 20 Avr 2019
thats it :)
Ali Afruzi
Ali Afruzi le 1 Avr 2022
In my case it was
date_out = TT.time2;

Connectez-vous pour commenter.

Plus de réponses (1)

Haris K.
Haris K. le 13 Mai 2020
You can also use directly:
TT = timetable(Temp,Pressure,WindSpeed,WindDirection, 'RowTimes',MeasurementTime)
datetime_vec = TT.Time

Catégories

En savoir plus sur Timetables dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by