matlab - Create vector of dates by start date and end date -


is possible create vector automatically or progressively dates. want ask user starting date , final date , i'd fill vector dates , ones between both.

so abstractly:

"what first date?" '...' firstdate = '...' --> "what final date?" '...' finaldate='...'

and following, i'd fill in vector of dates between firstdate , finaldate. possible in matlab, , how? there function use?

you can use linspace after user input:

%// prompt , user input prompt1 = 'what first date? (yyyy-mm-dd)\n'; prompt2 = 'what last date? (yyyy-mm-dd)\n';  startdate = datenum(input(prompt1,'s'),'yyyy-mm-dd') enddate = datenum(input(prompt2,'s'),'yyyy-mm-dd')  % number of days numdays = enddate-startdate  % array of dates alldays = linspace(startdate,enddate,numdays) datestring = datestr(alldays, 'mm/dd/yyyy') 

for input 1989-07-01 , 1989-07-07 return:

datestring =  07/01/1989 07/02/1989 07/03/1989 07/04/1989 07/05/1989 07/07/1989 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

mysql - FireDac error 314 - but DLLs are in program directory -