Autocomplete the datetime series

1 vue (au cours des 30 derniers jours)
Poulomi Ganguli
Poulomi Ganguli le 28 Août 2017
Modifié(e) : KL le 28 Août 2017
Hello, I have a time series as attached. The first, second, third and fourth column contains year, day, month, and hour, where the hour column runs from 0 - 23h. However, from 1st March, 23h onwards, no data are available. I want to create a datetime field from 1946, 2nd March onwards which ends at 31st December, with time frames 0-23 hrs. The value field can be filled with NaN in this case. Likewise, I have many sets of years and want to generalize the code in which the code can identify the enddate and endtime for which the data ends/missing and complete the datetime series till the end of the year, i.e.,
1946 12 31 23 NaN
Any help in this?

Réponse acceptée

KL le 28 Août 2017
Modifié(e) : KL le 28 Août 2017
something like this? Try with a bigger dataset with occasional gaps.
ts_ref = (datetime('01/01/1946 00:00:00'):hours(1):datetime('01/02/1946 00:00:00'))'; %timestamp with no gaps
ts_act = ts_ref;
ts_act(15:18)=[]; %create some gaps (your datetime vector)
val = rand(size(ts_act));
newVal = nan(size(ts_ref));
dummy_data = table(ts_act,val)
[~, ind_ts_ref, ind_ts_act] = intersect(ts_ref,ts_act);
newVal(ind_ts_ref) = val;
dummy_data_new = table(ts_ref,newVal)

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by