Combine Tables with different record rate
Afficher commentaires plus anciens
Hey Everybody,
I need to join two tables by the common Parameter "Time_secs_" which represents the record date of my sensor data. Unfortunately, in one table the record is 0.5 seconds while in the second it is 0.1 seconds. Therefore the second table has 481002 rows while the first only has 80167 rows.
Now I want to join them by their record rate and simply add blank cells for every signal from table 1 to the time_secs_0 0.1, 0.2, 0.25, 0.3, 0.4, 0.6, 0.7, 0.75, 0.8, 0.9 (some signals are also taken every 0.25 seconds, thats why 0.25 and 0.75 are included).
How can I do this? Is there any specification I can make to the "join"-function or will it not work with this at all?
Thanks a lot in advance!
6 commentaires
dpb
le 22 Juil 2018
Not precisely clear to me what you really intend as the result from description but you might look at resample-and-aggregate-data-in-timetable
Richard Vergin
le 23 Juil 2018
Walter Roberson
le 23 Juil 2018
If you can use timetable objects then call synchronize()
Richard Vergin
le 24 Juil 2018
Richard Vergin
le 24 Juil 2018
Peter Perkins
le 3 Août 2018
Richard, you can do that (use tables and joins), but if you are using R2016b or later, you will be much happier using timetables and synchronize:
>> tt1 = timetable((1:10)','RowTimes',seconds(0:1:9))
tt1 =
10×1 timetable
Time Var1
_____ ____
0 sec 1
1 sec 2
2 sec 3
3 sec 4
4 sec 5
5 sec 6
6 sec 7
7 sec 8
8 sec 9
9 sec 10
>> tt2 = timetable((11:15)','RowTimes',seconds(0:2:8))
tt2 =
5×1 timetable
Time Var1
_____ ____
0 sec 11
2 sec 12
4 sec 13
6 sec 14
8 sec 15
>> synchronize(tt1,tt2)
ans =
10×2 timetable
Time Var1_tt1 Var1_tt2
_____ ________ ________
0 sec 1 11
1 sec 2 NaN
2 sec 3 12
3 sec 4 NaN
4 sec 5 13
5 sec 6 NaN
6 sec 7 14
7 sec 8 NaN
8 sec 9 15
9 sec 10 NaN
But beware: .1 is not a nice floating point number. You may find that synchronize treats some times that look the same as different, because they are different. At that level of resolution, you are usually better off using the milliseconds function to construct time vectors than using the seconds function.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Tables dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!