join and synchronize two dataset with non uniform intervals
1 回表示 (過去 30 日間)
古いコメントを表示
ALESSANDRO D'ALESSANDRO
2021 年 8 月 17 日
編集済み: ALESSANDRO D'ALESSANDRO
2021 年 8 月 18 日
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')
1 件のコメント
その他の回答 (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!