필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
swathi
swathi 2020년 1월 26일
답변: woahs 2020년 1월 26일
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
dpb
dpb 2020년 1월 26일
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...

댓글을 달려면 로그인하십시오.

채택된 답변

woahs
woahs 2020년 1월 26일
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)

추가 답변 (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