How do I join two tables based on time to the second. attempts are yielding multiple rows
4 ビュー (過去 30 日間)
古いコメントを表示
I have two tables with one second data. Both tables have many 'blocks' of rows, and gaps in time between those blocks. My desired result is to NOT include rows for those gaps. Hence, I do not believe using synchronize (e.g. synchronize(T1, T2,'secondly','next') would work (resulted in a large expansion of the table to include filled-in data in those gaps).
Both T1 and T2 are tables (one was changed to table from timetable).
Time variable in both tables are class 'datetime'. I used the below to remove any data smaller than seconds (I think).
T1.Time = datetime(year(T1.Time),month(T1.Time),day(T1.Time),hour(T1.Time),minute(T1.Time),second(T1.Time));
The Time variable of both tables have different and overlapping ranges. My goal is to pull the data from T2 that corresponds to the Time in T1.
note: both tables have another key variable (e.g. key2) , which is not shown and not used in my attempt below. I might join the two tables from files that are already filtered for a specific key2 value, instead joining one large file that includes all groups defined by key2.
I tried
combined = outerjoin(T1,T2, 'Keys',{'Time'});
(I copied a portion of my matlab results into excel to create these graphics)

Any idea why the incorrect result?
0 件のコメント
回答 (1 件)
Walter Roberson
2022 年 12 月 2 日
移動済み: Walter Roberson
2022 年 12 月 5 日
Instead of using that particular code I suggest that you use dateshift(T1.Time, 'start', 'second')
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!