timetable retime error - input timetable must contain unique row times

22 views (last 30 days)
Sehoon Chang on 29 Sep 2020
Commented: Steven Lord on 29 Sep 2020
Hi all,
I'm having difficulties undertanding the error code that i am getting.
using the code as stated below, i am trying to retime the timetable value for every 15 minutes.
timetable = unique(timetable)
dt = minutes(15);
timetable = retime(timetable,'regular','linear','TimeStep',dt);
The timetable looks as displayed below... The error code that i am getting is as following:
"Error using timetable/retime (line 140)
Input timetables must contain unique row times when synchronizing using 'linear'."
What may be the problem here, and how may i solve it?
thank you.

Steven Lord on 29 Sep 2020
First, don't name a variable timetable. That already has a meaning in MATLAB.
Second, at least two rows of your timetable (which I'm going to call TT) have the same value for their RowTimes.
X = TT.Properties.RowTimes;
any(X(1:end-1) == X(2:end)) % likely returns true
v1 = [1:5 5:10];
v2 = 1:numel(v1);
plot(v1, v2, 'o-')
If I wanted to interpolate THE value of v2 when v1 = 5, what should that ONE value be? 5, 6, 5.5, NaN (since it's not unique), etc.?
How you fix that problem will depend on your specific data and the problem you're trying to solve.
Steven Lord on 29 Sep 2020
Take the first row in the timetable with the same date and time data?
Take the last row in the timetable with the same date and time data?
Take the mean along the variables of the rows in the timetable with the same date and time data?
Take the min or max value of each variable of the rows in the timetable with the same date and time data?
It really depends what the data represents. One could probably come up with scenarios where each of those would be appropriate. One such scenario involves multiple simultaneous bank transactions being posted to your account, especially if you have automatic bill paying enabled. Which account balance will your bank use to determine if it should charge you an overdraft fee?