How can I create a linspace vector using date commands
Show older comments
I am trying to create a domain for a plot starting from datenum(now) to five days from today with a total of four days in between points.
I am proceding the following way
b = datestr(datenum(now),1)
a = datestr(datenum([0000 00 5]),1)
c = datestr(datenum([0000 00 1]),1)
x = linespace(datestr(b,[a + b],c))
I want MATLAB to output a vector of days starting from now (TODAY) and ending five days from TODAY with a total of four days in beetwen dates (n = 1; on linspace command).
Can you please help?
Accepted Answer
More Answers (2)
Azzi Abdelmalek
on 27 Sep 2012
Edited: Azzi Abdelmalek
on 27 Sep 2012
number_day=4
v=datevec(now)
out=datestr(datenum(v(1),v(2),v(3):v(3)+number_day,v(4),v(5),v(6)))
v(1) to incremante ..years
v(2) ...................... months
v(3) .......................days
v(4) ........................hours
v(5) ........................minutes
v(6) ........................secondes
Andrei Bobrov
on 27 Sep 2012
out = datestr(now:now+number_day-1)
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!