Input timetables must contain unique row times when synchronizing using 'linear'

24 views (last 30 days)
I tried running the below code but I'm shown an error something like this,
Input timetables must contain unique row times when synchronizing using 'linear'
T.Time = days(T.Time);
T.Time.Format = "hh:mm:ss.SSS";
TT = table2timetable(T,'RowTimes','Time');
head(TT);
D = readtable('DIC.xlsx');
D.Time = days(D.Time);
D.Time.Format = "hh:mm:ss.SSS";
DD = table2timetable(D,'RowTimes','Time');
data = synchronize(TT,DD,"secondly","linear");
I also tried to use Live Editor --> Task button ---> synchronous Timetable and I'm not able to find "interpolation" in the scroll down.
Please share your suggestions.
Thanks,

Answers (1)

Peter Perkins
Peter Perkins on 2 Mar 2022
The problem is that one of these files has duplicate rows:
>> t1 = readtable('ctm.xlsx');
>> t1.Time = days(t1.Time); t1.Time.Format = "hh:mm:ss.SSS";
>> tt1 = table2timetable(t1);
>> t2 = readtable('DIC.xlsx');
>> t2.Time = days(t2.Time); t2.Time.Format = "hh:mm:ss.SSS";
>> tt2 = table2timetable(t2);
>> tt1(tt1.Time == 0,:)
ans =
2×1 timetable
Time Deflection
____________ __________
00:00:00.000 0
00:00:00.000 0.034
>> tt1(tt1.Time == "00:09:02.700",:)
ans =
4×1 timetable
Time Deflection
____________ __________
00:09:02.700 2.712
00:09:02.700 2.712
00:09:02.700 2.712
00:09:02.700 2.712
This would be easy to clean up by hand, but in general, the way to remove exact duplicate rows would be retime. But it's not clear what to do with those first two rows that have different Deflection values. Let's say, take the sum:
>> tt1u = retime(tt1,unique(tt1.Time),"sum")
tt1u =
11825×1 timetable
Time Deflection
____________ __________
00:00:00.000 0.034
00:00:00.200 0.034
00:00:00.400 0.034
00:00:00.600 0.034
00:00:00.900 0.034
[snip]
And then this works:
>> data = synchronize(tt1u,tt2,"secondly","linear")
data =
2673×2 timetable
Time Deflection Outofplane
____________ __________________ ___________________
00:00:00.000 0.034 0
00:00:01.000 0.034 -0.0304169823710666
00:00:02.000 0.034 -0.0597900517877678
00:00:03.000 0.036 -0.0387827506926043
00:00:04.000 0.039 -0.0184773732647037
[snip]

Categories

Find more on Timetables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!