Built in look-up style interpolation of timetables for non-numeric data?
Show older comments
Is there no built-in function similar to interp1 for numeric data, that can operate on timetables with arbitrary data types?
Some random illustrative data:
x = 1:10; % numeric x values
y = sin(x); % numeric y values
t = datetime()+(1:10); % datetime x values
yNN = "foo"+strings(1,10); % non-numeric y values
yNN(3:6) = "bar"; % non-numeric y values
T = timetable(t',yNN',y')
With interp1, we can take a "series" and interpolate on it with arbitrary (unsorted, repeated) values:
xProbe = [4 4 6 2 1 1 9];
yProbe = interp1(x,y,xProbe,"nearest")
However, it appears we cannot use timetable tools like retime or synchronize to do something similar on timetables...
tProbe = t(xProbe)
R = retime(T,tProbe,"nearest")
One also cannot use interp1 on non-numeric data
% yProbe = interp1(x,yNN,xProbe,"nearest") % uncomment to see it does not work
so that we cannot even do a simple hack like
% yProbe = interp1(seconds(t-datetime()),yNN,seconds(tProbe-datetime()),"nearest");
I can think of several ways to implement what I ultimately want, but is there some built in analog to "interp" function to operate on timetables that I am just not finding?
Accepted Answer
More Answers (0)
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!