MATLAB: How to interpolate datetime variables

datetimeinterpolate

Hey everyone! I am new to Matlab and am trying to interpolate datetime variables so I have measurements secondly. The data I got now skips a few seconds. I am using 2016a, so I can't really use retime. And I have tried using datenum but wasn't successful. I want to have a plot with the secondly datetime variable and them pinpoint especific times.
plot(tide.tide.StationDateTime,tide.tide.WaterLevel)
hold on
output = [];
for i = 1 : length(tide.tide.StationDateTime)
output = ismember(tide.tide.StationDateTime,Log.Log.Date);
if tide.tide.StationDateTime(output,:)==tide.tide.StationDateTime(i);
plot(tide.tide.StationDateTime,tide.WaterLevel,'Marker','o','Color','r')
end
end
where tide.tide.StationDateTime is the variable I need to interpolate and Log.Log.Date is the time that I want to pinpoint in my plot.
Thanks guys

Best Answer

It works for me. Tested in R2016a and R2016b.
B = datetime() + hours([0 1 2 3 5 6.2 7]); %some times to define the data at
Y = rand(1,length(B)); %some data
C = B(1)+hours(0:7); %some times to interpolate the data at
Yinterp = interp1(B, Y, C); %what the data should be