Add missing time data
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, i have in excel 2 columns, A for time data DD/MM/YYYY HH:MM:SS and the other column are values from a variable X1.
and i want to create all the missing data time with a frequency of 1 min, and the X1 value being a blank cell or N/A something like that.
I have tried with a excel macro vba, but the excel always crashes so i wanted to know if it is possible to do that in matlab
0 commentaires
Réponses (1)
Peter Perkins
le 19 Déc 2017
Your data run from 1-Jan-2016 to 31-Dec-2016. There are
>> minutes(diff(datetime(2016,[1 12],[1 31])))
ans =
525600
minutes in 2016. Do you really want that many rows? You can do it, but let's assume you really meant every 30 minutes. Using timetables, introduced in R2016b,
>> t = table2timetable(readtable('U1200 - Massa Vol£mica (1).xlsx'));
>> head(t)
ans =
8×1 timetable
Date X1
____________________ ______
01-Jan-2016 00:00:00 0
03-Jan-2016 05:00:00 0.7353
04-Jan-2016 04:30:00 0.7338
08-Jan-2016 04:30:00 0.7404
11-Jan-2016 04:30:00 0.7393
13-Jan-2016 11:30:00 0.736
15-Jan-2016 04:30:00 0.7356
18-Jan-2016 04:30:00 0.7398
>> regularTimes = datetime(2016,1,1,'Format','dd-MMM-yyyy HH:mm:ss'):minutes(30):datetime(2016,12,13,23,30,0);
>> t2 = retime(t,regularTimes);
>> head(t2)
ans =
8×1 timetable
Date X1
____________________ ___
01-Jan-2016 00:00:00 0
01-Jan-2016 00:30:00 NaN
01-Jan-2016 01:00:00 NaN
01-Jan-2016 01:30:00 NaN
01-Jan-2016 02:00:00 NaN
01-Jan-2016 02:30:00 NaN
01-Jan-2016 03:00:00 NaN
01-Jan-2016 03:30:00 NaN
2 commentaires
Walter Roberson
le 20 Déc 2017
datetime(2016,12,13,23,30,0)
That is year 2016, month 12, day 13, hour 23, minute 30, seconds 0
Voir également
Catégories
En savoir plus sur Dates and Time 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!