Add time to a datetime array

11 Ansichten (letzte 30 Tage)
Arthur Leon
Arthur Leon am 9 Mär. 2021
Beantwortet: Cris LaPierre am 9 Mär. 2021
I have to select the hourly value of relative air saturation and temperature at 14:05 a clock.
From an datetime array containing the 10 minutes values of all dates i created an daily datetime array using:
dt = table2array(T(:,3 ));
dt = datetime(dt, 'InputFormat', 'dd-mmm-yyyy HH-MM-SS');
dt_daily = dt(1:144:end);
how can i add to each dt_daily 14 hours so that i have an index to extract the respective values from the table?
Thanks a lot for your help!
Best regards,
Arthur

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 9 Mär. 2021
I would use the datetime values you already have in your table T.
load T_matlab.mat
ind = timeofday(T.DateTime) == duration(14,05,0);
dayT = T(ind,["DateTime","H_air___","T_air_C_"])
dayT = 101x3 table
DateTime H_air___ T_air_C_ ____________________ ________ ________ 01-Jun-1994 14:05:00 42.31 24.5 02-Jun-1994 14:05:00 48.54 26.48 03-Jun-1994 14:05:00 50.68 20.18 04-Jun-1994 14:05:00 81.76 11.91 05-Jun-1994 14:05:00 68.11 13.05 06-Jun-1994 14:05:00 60.32 15.06 07-Jun-1994 14:05:00 73.92 19.11 08-Jun-1994 14:05:00 53.23 24.73 09-Jun-1994 14:05:00 52.18 13.98 10-Jun-1994 14:05:00 75.54 13.52 11-Jun-1994 14:05:00 66.84 13.47 12-Jun-1994 14:05:00 59.88 17.12 13-Jun-1994 14:05:00 50.32 20.29 14-Jun-1994 14:05:00 64.19 18.04 15-Jun-1994 14:05:00 60.82 21.16 16-Jun-1994 14:05:00 56.84 20.52
See this page for more on how to access data in a table.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by