How do you create an array of date times given a starting date and number of days?

15 Ansichten (letzte 30 Tage)
I want to start at Jan/1/1900 and given the length of a vector, generate a vector of dates with 1 day intervals
e.g.
Vector1 = [1 2 3 4 5 6]
I want to create a datetime vector that will ouput
Datetimevector = [Jan/1/1900, Jan/2/1900, Jan/3/1900, Jan/4/1900, Jan/5/1900, Jan/6/1900]
I've tried to search the syntax for something that will give this output but I can't seem to find it.
Thanks in advance!

Akzeptierte Antwort

Rik
Rik am 5 Nov. 2021
Vector1=1:5;
Datetimevector = datetime(1900,1,1)+days(1:numel(Vector1))
Datetimevector = 1×5 datetime array
02-Jan-1900 03-Jan-1900 04-Jan-1900 05-Jan-1900 06-Jan-1900

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by