how to concatenate two tables into one such that the timestamps of two tables are in sequence and the corresponding values are arranged according to their timestamps

16 ビュー (過去 30 日間)
i have two tables with engine data such that in the first table the first column contains timestamp and second column contains speed data, in the second table the first column is a timestamp and the second column is gear data. i want to make these two tables to one such that the first column contains timestamps of both tables arranged in a sequence and then the second and third column contains their corresponding speed and gear values respectively.
i used code such as t = [t1 t2];
but this does not arrange them in a sequence.
also i dont know how to write the speed and gear values corresponding to their timestamps.
can someone help me with this problem please
  1 件のコメント
J. Alex Lee
J. Alex Lee 2020 年 3 月 5 日
when you say "table" do you mean, in terms of matlab data types, an actual table? or are you actually using matlab arrays?
class(t1)
class(t2)
Are your timestamps the same in both sets of data such that you have both gear and speed data at the same times? If this is not the case, what do you expect to fill in the missing data?

サインインしてコメントする。

回答 (1 件)

Guillaume
Guillaume 2020 年 3 月 5 日
It should be very easy. Convert your tables to timetables (if they're not already) then call synchronize:
speedtimetable = table2timetable(yourspeedtable);
geartimetable = table2timetable(yourgeartable);
speedandgear = synchronize(speedtimetable, geartimetable);
in theory. If this doesn't work then attach a mat file with your two tables.
  1 件のコメント
amir-nejati
amir-nejati 2023 年 4 月 22 日
The only issue with this solution is when in one of your table or timetable there are some rows with the same timestamp, in that case the synchronize function will ignore one of the rows,any idea how to solve that problem?
Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by