error using the retime function

9 views (last 30 days)
Emily Browning
Emily Browning on 23 May 2019
Answered: Karun Mathiazhagan on 26 May 2019
Hi,
I keep getting an error message when I try to retime my timetable data. I have tried using both linear and nearest interpolation methiods. My time step is only a fraction of a second, that could be a the source of the issue but I have retimed data using small time steps before. I have attached a few lines of my code and the resulting error message.
dt=0.4
Data= timetable
dt=seconds(dt);
Data=unique(Data,'sort','rows');
%FTT = retime(Data, 'regular','nearest','TimeStep',dt);
FTT = retime(Data,'regular','linear','SampleRate',2.3077)
Error using timetable/retime (line 140)
Input timetables must contain unique row times when synchronizing using 'linear'.

Answers (1)

Karun Mathiazhagan
Karun Mathiazhagan on 26 May 2019
Hello Emily,
It is my understanding that you are trying to retime a timetable but are encountering an error message relating to non-unique row times.
I used a non-empty timetable in R2019a like in the documented example linked below instead of the empty one (just "timetable") since the empty timetable would throw a different error:
Capture.PNG
However, I had to change TT1 to have repeated time values in the first two entries so as to be able to reproduce the error.
It was then that I noticed that the following command was probably being used to ensure that there were no repeated timestamps.
>> Data = unique(Data,'sort','rows');
If this is the case, kindly note that this command would not achieve this. It would simply make sure that the rows as a whole are unique and not necessarily the timestamp. You would need to extract the "Time" column of the timetable and extract the unique indices first (using "unique") and then use these indices to subscript into "Data".
This would ensure that the timestamps are unique. I hope this helps.
Best,
Karun

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!