How can I interpolate datetime variables?

81 ビュー (過去 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
  1 件のコメント
Larissa Perez
Larissa Perez 2016 年 10 月 7 日
thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by