day of year

Date vectors converted to day of the year.
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).

julday = datevec2doy(mydate)

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

julday: An Nx1 array of julian days.

%Take the current day and add normally distributed random days to the

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 (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
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

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

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