How can I interpolate datetime variables?

조회 수: 75 (최근 30일)
Larissa Perez
Larissa Perez 2016년 10월 7일
댓글: Larissa Perez 2016년 10월 7일
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에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by