Effacer les filtres
Effacer les filtres

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

6 vues (au cours des 30 derniers jours)
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 commentaire
J. Alex Lee
J. Alex Lee le 5 Mar 2020
when you say "table" do you mean, in terms of matlab data types, an actual table? or are you actually using matlab arrays?
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?

Connectez-vous pour commenter.

Réponses (1)

Guillaume le 5 Mar 2020
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 commentaire
amir-nejati le 22 Avr 2023
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?

Connectez-vous pour commenter.


En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by