Calculate the number of days in a year
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Is it possible to calculate the number of days in a year without having to put the year? If so how? Also i'm doing this on an m-file.
0 Kommentare
Antworten (2)
Royi Avital
am 21 Apr. 2013
I would go something like that:
firstDayInYear = '01/01/2012';
lastDayInYear = '31/12/2012';
firstDayInYearNum = datenum(firstDayInYear, 'dd/mm/yyyy');
lastDayInYearNum = datenum(lastDayInYear, 'dd/mm/yyyy');
numDaysInYear = lastDayInYearNum - firstDayInYearNum + 1;
That's it...
0 Kommentare
per isakson
am 21 Apr. 2013
Or one of
y = 2002;
datenum([y+1,1,1]) - datenum([y,1,1])
sum( eomday( y, [1:12] ) )
0 Kommentare
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!