Date to Decimal Day of Year
by Anthony Kendall
14 Jan 2008
(Updated 28 Apr 2009)
Convert a vector of MATLAB serial dates to decimal days since the start of the year.
|
Watch this File
|
| File Information |
| Description |
This function calculates the decimal day of the year of the input vector of dates. The dates must be in MATLAB serial date format.
For example, for datestr(now), MATLAB produces: "18-Jan-2008 14:33:27". The output of this function, called "date2doy" yields-
date2doy(now): "18.60662".
There are two outputs, the decimal date (can be a vector), and the fraction of the year completed by that date. From the example above, the fraction of the year is: "0.0481"
This function is very fast, and is ideal for embedding in larger applications that call date2doy many times. |
| Acknowledgements |
This submission has inspired the following:
Day of Year to MATLAB date
|
| MATLAB release |
MATLAB 7.4 (R2007a)
|
| Other requirements |
Should work in all recent versions of MATLAB. |
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 18 Jan 2008 |
In response to James' review, I've heavily modified this function and taken all of his suggestions. Also, the calculation, while simple, is not as trivial as James mentions. |
| 28 Apr 2009 |
Submitted modified file to FEX as detailed in file description. |
|
Contact us at files@mathworks.com