day of year

Date vectors converted to day of the year.
2.8K Downloads
Updated 25 Jun 2010

View License

Takes a date vector and returns the day of year, known incorrectly in the Geophysical community as the Julian calender day, i.e. 12/31/2005 is returned as day 365, day 06/22/2010 is returned as 173, etc... The function is vectorized. This function needs etime.m (R2009a and later).

USAGES
julday = datevec2doy(mydate)

INPUT
mydate: Either a 6xN or Nx6 array of date vectors, as output by
functions like datevec.

OUTPUT
julday: An Nx1 array of julian days.

-----------------------------------------------------------------------
EXAMPLE
%Take the current day and add normally distributed random days to the
%date.

tadd = randn(1,12);
mydate = datevec(now)';
mydate = repmat(mydate,1,12);
mydate(2,:) = mydate(2,:) + tadd;
day = datevec2doy(mydate);

Cite As

Joshua Carmichael (2024). day of year (https://www.mathworks.com/matlabcentral/fileexchange/27989-day-of-year), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Dates and Time in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.2.0.0

changed title; previous title was misuse of Julian Days common definition

1.1.0.0

name was inappropriate, and now it handles 6xN or Nx6 date arrays.

1.0.0.0