day of year

Date vectors converted to day of the year.

You are now following this Submission

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 (2026). day of year (https://www.mathworks.com/matlabcentral/fileexchange/27989-day-of-year), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
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