Effacer les filtres
Effacer les filtres

how to compare 2 data files parallel and take data based on matching time?

1 vue (au cours des 30 derniers jours)
swathi
swathi le 26 Jan 2020
Réponse apportée : woahs le 26 Jan 2020
A file data( it reads the data at every 100ms or 0.1s),it starts the time on 2s and it ends on 6s
time height velocity distance
2 23.12 103.12 21.2
2.1 23.13 103.15 21.5
2.2 23.15 103.2 21.52
2.3 23.25 103.25 21.65
2.4 23.35 103.36 21.7
2.5 23.37 103.45 21.75
2.6 23.45 103.52 22.21
2.7 23.56 103.58 22.25
2.8 23.86 103.65 22.56
2.9 23.95 103.72 22.78
3 24 103.78 23
......................................its continious goes on upto 6
B file data (it reads the data at every 1s),it starts on 3s and it ends on 6s
time height velocity distance
3 24 103.78 23
4 25 104.78 24
5 26 105.78 25
6 27 105.78 26
based on time match it will take data
it will check A file time to B file time
if any time match is there it reads data
i used ismember function
but i want to write complete code on how to read both files based on time
  1 commentaire
dpb
dpb le 26 Jan 2020
Use the timetable object and can merge/interpolate to heart's content.
However, as you've described the desired result, there seems no need for file A; all the data you're interested in is in B and A is simply a subset therefrom it appears.
Surely there's something else going on here...

Connectez-vous pour commenter.

Réponse acceptée

woahs
woahs le 26 Jan 2020
Like dpb said above, it's unclear what the desired output is from the example data you've provided is.
From what I can understand, I assume you want to return just the rows that have a common time value in both sets. In which case, you can use intersect to get the intersection of the two time vectors.
Table_A = array2table(...
[2 23.12 103.12 21.2;...
2.1 23.13 103.15 21.5;...
2.2 23.15 103.2 21.52;...
2.3 23.25 103.25 21.65;...
2.4 23.35 103.36 21.7;...
2.5 23.37 103.45 21.75;...
2.6 23.45 103.52 22.21;...
2.7 23.56 103.58 22.25;...
2.8 23.86 103.65 22.56;...
2.9 23.95 103.72 22.78;...
3 24 103.78 23], ...
'VariableNames', {'time', 'height', 'velocity', 'distance'});
Table_B = array2table(...
[3 24 103.78 23;...
4 25 104.78 24;...
5 26 105.78 25;...
6 27 105.78 26], ...
'VariableNames', {'time', 'height', 'velocity', 'distance'});
Table_C = intersect(Table_A, Table_B)

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Identification dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by