making an input to an array

1 visualizzazione (ultimi 30 giorni)
lowcalorie
lowcalorie il 22 Feb 2012
i need my input which will be a date for example 08/31/2011 and make it into an array. every time i do my input matlab returns me a decimal because it is just dividing the 3 numbers. unfortunately i need to use the slashes.
can anyone help i am using the inptut('') function to ask the user the input a date in xx/xx/xxxx format and then my program needs to display the number day out of 365 and the day of the week for example Tuesday
here is my script so far
n = input('Enter month, day and year in the form xx/xx/xxxx for 2012, 2011, or 2012: ')

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 22 Feb 2012
d = input('enter date in view: mm/dd/yyyy -> ','s')
[s,s] = weekday(d)
dv = datevec(d);
numdayinyear = diff(datenum([dv(1) 1 1;dv(1:3)]))+1

Più risposte (1)

Sean de Wolski
Sean de Wolski il 22 Feb 2012
doc datestr
doc input %specifically look at the 's' option

Categorie

Scopri di più su Time Series Objects in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by