How can I interpolate datetime variables?

65 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2016-10-7
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by