Join tables on closest dates

3 visualizzazioni (ultimi 30 giorni)
Frederick Awuah-Gyasi
Frederick Awuah-Gyasi il 3 Nov 2022
Risposto: Steven Lord il 3 Nov 2022
CB = {
1.1 2.4 '16-Dec-2021 14:36:02'
1.1 2.5 '16-Dec-2021 14:46:17'
1.2 2.6 '16-Dec-2021 14:56:32'
1.3 4.6 '16-Dec-2021 15:06:47'
3.4 4.5 '16-Jan-2021 15:17:02'
2.3 1.2 '16-Jan-2021 15:27:17'
1.1 2.4 '16-Jan-2021 14:36:02'
1.1 2.5 '16-Jan-2021 14:46:17'
1.2 2.6 '16-Jan-2021 14:56:32'
1.3 4.6 '16-Feb-2021 15:06:47'
3.4 4.5 '16-Feb-2021 15:17:02'
2.3 1.2 '16-Feb-2021 15:27:17'
};
CA = {
'A' 2 '2021.12.16.14.30.23'
'B' 4 '2021.01.16.14.28.23'
'C' 0 '2021.02.16.14.30.23'
};
T1 = cell2table(CA, 'VariableNames',{'X','Y','DateTime'})
T2 = cell2table(CB, 'VariableNames',{'A','B','Datetime'})
The goal is have a join(T1,T2,'DateTime',1, Datetime,2) using the nearest date so this should result in just a 3 rowed tabled. Any help.

Risposte (1)

Steven Lord
Steven Lord il 3 Nov 2022
I'd probably try converting those table arrays to timetable arrays using table2timetable and then using synchronize to synchronize them to a common time basis.

Categorie

Scopri di più su Language Fundamentals in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by