Calculate difference between datasets (timetables) with uneven size

16 次查看(过去 30 天)
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