Add missing time data
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Peter Perkins
2017-12-19
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 个评论
Walter Roberson
2017-12-20
datetime(2016,12,13,23,30,0)
That is year 2016, month 12, day 13, hour 23, minute 30, seconds 0
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!