Combine Tables with different record rate

5 次查看(过去 30 天)
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 个评论
Richard Vergin
Richard Vergin 2018-7-24
For interested readers: after adding a Time-Column with similar values (thanks to Guillaume's solution) I was able to combine the tables. Outerjoin works for adapting the fine record rate, joing for adapting the small one.
Peter Perkins
Peter Perkins 2018-8-3
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.

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2018-7-24
How can I create an additional column within the table which contains all the information of those three others and makes a time out of this?
yourtable.newcolumnname = datetime([zeros(height(yourtable), 3), yourtable.hourcolumn, yourtable.minutecolumn, yourtable.secondcolumn], 'Format', 'HH:mm:ss')
  5 个评论
Walter Roberson
Walter Roberson 2018-10-13
What is the
zeros(height(Minus22_FlightParameter_Hydraulics_Uniform_Table),6),
part there for? That is going to generate 6 columns of zeros, and then you add on 6 more columns of numeric values, for a total of 12 columns.
Richard Vergin
Richard Vergin 2018-10-13
Ah I don’t Know I just reused that code line. But without it works perfectly fine, thanks a lot! :)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by