How can I interpolate datetime variables?
75 views (last 30 days)
Show older comments
Larissa Perez
on 7 Oct 2016
Commented: Larissa Perez
on 7 Oct 2016
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
0 Comments
Accepted Answer
Walter Roberson
on 7 Oct 2016
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
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!