フィルターのクリア

Add values to reference time

1 回表示 (過去 30 日間)
Arthur Batte
Arthur Batte 2020 年 7 月 16 日
コメント済み: Arthur Batte 2020 年 7 月 16 日
Hello I have the following code below. LoD shows 3 diffrent reference times. tim is the time vector. I wish to add tim to each of the LoDs to generate 3 different sets of times. The problem is that when i try to add tim to a LoD the values in tim with decimal places are truncated. eg 0.5 is truncated to 0 and 1.5 is truncated to 1 and so on. How could i suppress the truncation while using every value in tim. How can i output the results from this loop. Kindly advise
LoD = ['2006-01-10 18:20:12'; '2006-02-14 14:25:10'; '2006-03-17 11:13:14'];
tim = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4];
for x= 1:length(LoD)
newdates = datestr(addtodate(datenum(LoD(x,1:19)), length(tim), 'sec'));
end
  1 件のコメント
Arthur Batte
Arthur Batte 2020 年 7 月 16 日
Thank you

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 7 月 16 日
LoD = ['2006-01-10 18:20:12'; '2006-02-14 14:25:10'; '2006-03-17 11:13:14'];
tim = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4];
basetimes = datetime(LoD);
temp = arrayfun(@(T) T+seconds(tim), basetimes, 'uniform', 0);
newdates = vertcat(temp{:});

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by