join and synchronize two dataset with non uniform intervals
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am a new user of Matlab.
I need to joind the two datase DB1 and DB2 using the datetime of DB1 to create a new DB2 that has average values based on the datetime of DB1 (see attached files).
I tried to use retime function but I do not understand how to prepare the NewTimes vector as required.
"TT2 = retime(TT1,newTimes,method) adjusts the timetable variables data to the time vector newTimes, using the method specified by method. The newTimes time vector can be irregular, but it must be a sorted datetime or duration vector and contain unique values. The times in newTimes become the row times of TT2."
Any suggestion?
Thanks in advance
Alessandro
0 个评论
采纳的回答
Cris LaPierre
2021-8-17
编辑:Cris LaPierre
2021-8-17
It looks like there are 409 unique times in DB1. I would use groupsummary to create your summary table with groups defined by the time intervals from DB1, and the area info in DB2. That appears to result in 250 groupings
load DB1.mat
load DB2.mat
tmInterval = unique(DB1.datetime(~ismissing(DB1.datetime)));
newDB2 = groupsummary(DB2,"DateTime",tmInterval,'mean')
If you would like to have a row for each of the 409 times, you could try this approach using retime. Just note that I have not independently verfied that the mean areas are correct.
DB1TT = table2timetable(DB1);
DB2TT = table2timetable(DB2);
newTimes = unique(DB1TT.datetime(~ismissing(DB1TT.datetime)));
TT2 = retime(DB2TT,newTimes,'mean')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!