How do I join two tables based on time to the second. attempts are yielding multiple rows
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 2 de Dic. de 2022
Movida: Walter Roberson
el 5 de Dic. de 2022
Instead of using that particular code I suggest that you use dateshift(T1.Time, 'start', 'second')
1 comentario
Ver también
Categorías
Más información sobre Data Type Identification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!