File Exchange

image thumbnail

Day of Year to MATLAB date

version 1.1 (1.68 KB) by

Converts a day of year number and a year to a date in MATLAB format

40 Downloads

Updated

View License

DOY2DATE.m will convert a vector of day of year numbers and years
and convert them to MATLAB date format.
 
Sample Call:
 doyV = [54;200.4315];
 yearV = [2009;2009];
 [dateV] = doy2date(doyV,yearV);

Inputs:
 doyV -> vector of day of year numbers (n x 1)
 yearV -> vector of years (n x 1)

Outputs:
 dateV -> vector of MATLAB dates (n x 1)

function [dateV] = doy2date(doyV,yearV)
z = zeros(length(yearV),5);
dv = horzcat(yearV,z);
dateV = doyV + datenum(dv);

Comments and Ratings (6)

satish kumar

defsdf dfe

Alfonso

D

D (view profile)

Liisa

Liisa (view profile)

alexzhao zhao

Salman

Salman (view profile)

Your script was helpful in finding out the "key" 3 lines of code that did the job for me:
z = zeros(length(yearV),5);
dv = horzcat(yearV,z);
dateV = doyV + datenum(dv);

Updates

1.1

fixed typo in title

MATLAB Release
MATLAB 7.4 (R2007a)
Acknowledgements

Inspired by: Date to Decimal Day of Year

Inspired: F10.7 Solar Flux & Ap Indices

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video