I want to create a date vector in serial format. I know the end date, e.g, 21st June 2018, but I wish to be able to go lets say 500 period back from this date in either daily or weekly steps. The end date should be at the bottom of the vector. Any help? Any functions I can use for this, with input of end date and time step?
I have attempted the following. It works, but is there a better way? A function perhaps?
enddate = datenum(2018, 6, 21, 0, 0, 0); % Next, use datenum again to define the interval of 7 days: offset = datenum(0, 0, 7, 0, 0, 0);
% Finally, make a 250-element vector by multiplying the numbers 0 through 249 by the % offset and adding them to the start date:
vec = enddate - (0:249)*offset; %You can verify the results by converting the serial date numbers in vec back to strings: Thedateseries = datestr(vec);
Thedateseriesrev = flipud(Thedateseries);