Merge into table from two matlab tables with different date/time format

5 vues (au cours des 30 derniers jours)
I have two Matlab tables and want to merge into, but the time intervals are different. thanks in advance
  • Table TEST_1 with the time intervals of 3 hours and the key data DINDEX.
DUT DINDEX
2018/8/4 0.7
2018/8/4 3:00:00 1.3
2018/8/4 9:00:00 0.7
2017/8/4 9:00:00 0.7
2018/10/5 0
2018/10/5 9:00:00 0.3
2018/10/5 18:00:00 1
2018/10/5 21:00:00 0.7
2018/10/10 0.7
for example,
the first row show time range is between 2018/8/4 00:00:00 and 2018/8/4 3:00:00 with 3 hours time interval.
the second row show time range is between 2018/8/4 3:00:00 and 2018/8/4 6:00:00 with 3 hours time interval, and so forth
  • DATE of Table TABLE_2 has no regular.
UT KP
2018/8/4 1:02:05.421000
2018/8/4 4:02:06.921000
2018/8/4 9:02:08.421000
2017/8/4 9:02:09.921000
2018/10/5 1:02:11.421000
2018/10/5 10:02:14.421000
2018/10/5 19:02:15.921000
2018/10/5 21:02:17.421000
2018/10/10 0:02:18.921000
  • And now, I want to merge into the field KP of Table TEST_2 using the key data DINDEX in Table TEST_1 by time, what I expect is:
UT KP
2018/8/4 1:02:05.421000 0.7
2018/8/4 4:02:06.921000 1.3
2018/8/4 9:02:08.421000 0.7
2017/8/4 9:02:09.921000 0.7
2018/10/5 1:02:11.421000 0
2018/10/5 10:02:14.421000 0.3
2018/10/5 19:02:15.921000 1
2018/10/5 21:02:17.421000 0.7
2018/10/10 0:02:18.921000 0.7
the first UT (2018/8/4 1:02:05.421000) is between 2018/8/4 00:00:00 and 2018/8/4 3:00:00, so the KP of the first UT is 0.7, corresponds to the first DINDEX.

Réponse acceptée

Corey Silva
Corey Silva le 18 Mai 2022
If you convert both of these tables to timetables, you should be able to synchronize them together easily.
TEST_1 = table2timetable(TEST_1);
TEST_2 = table2timetable(TEST_2);
TEST = synchronize(TEST_1,TEST_2);
I may be misinterpretting your question though.
You may be looking for a join operation instead. You can use the join method with two timetables, as well.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by