필터 지우기
필터 지우기

Calculate difference between datasets (timetables) with uneven size

조회 수: 16 (최근 30일)
Renan Deuter
Renan Deuter 2022년 7월 20일
댓글: Siddharth Bhutiya 2022년 7월 22일
Hello,
I have two timetables timetableA and timetableB from two different sensors. One sensor does record data (here: Height) every second, while the other records in milliseconds. Therefore they don't have the same length.
Now I want to calculate the difference (for each second) between these two heights. The easist idea would be to just use
diff = timetableA.Height - timetableB.Height
However, they don't have the same length, so this doesn't work.
The next idea, was using intersect.
[sharedvals,idA, idB] = intersect(timetableA.Time,timetableB.Time,'stable');
However, the sensors aren't synchronized so most of the time, their timestamps don't intersect.
For example:
Sensor A:
timetableA.Time = [12:41:34.33 12:41:34:56 12:41:34:99 12:41:35:03 ....]
timetableB.Time = [12:41:35:00 12:41:36:00]
So while 12:41:34:99 would be a very close match, the function can of course not find it.
Next I tried
>> TT = synchronize(timetableA, timetableB)
but I got the error:
"Target time vector for synchronization must be sorted (increasing or decreasing) and cannot contain missing times."
(Both tables are sorted and don't have NaT)
Is there a better way to compare the differences between the data?
Best Regards,
Renan
  댓글 수: 1
Siddharth Bhutiya
Siddharth Bhutiya 2022년 7월 22일
The error message is correct timetableA contains one NaT row.
>> find(ismissing(timetableA.DateTime))
ans =
1086
>> timetableA(1086,:)
ans =
timetable
DateTime Heigth
________ ______
NaT 595.36
Once you fix that you should be able to sychronize the two timetable, however, you would need to figure out how you want to line up the values to ensure that you get the correct difference. I would suggest going through the documentation of synchronize (link here) to figure out what time vector you want in the output timetable and how you want to resample the height values.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by