필터 지우기
필터 지우기

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

채택된 답변

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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by