Azzera filtri
Azzera filtri

Add values to reference time

1 visualizzazione (ultimi 30 giorni)
Arthur Batte
Arthur Batte il 16 Lug 2020
Commentato: Arthur Batte il 16 Lug 2020
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

Risposta accettata

Walter Roberson
Walter Roberson il 16 Lug 2020
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{:});

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by