join and synchronize two dataset with non uniform intervals
1 view (last 30 days)
Show older comments
ALESSANDRO D'ALESSANDRO
on 17 Aug 2021
Edited: ALESSANDRO D'ALESSANDRO
on 18 Aug 2021
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 Comments
Accepted Answer
Cris LaPierre
on 17 Aug 2021
Edited: Cris LaPierre
on 17 Aug 2021
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')
1 Comment
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!