Code covered by the BSD License

### Highlights from Day of Year to MATLAB date

5.0
5.0 | 5 ratings Rate this file 25 Downloads (last 30 days) File Size: 1.68 KB File ID: #24235 Version: 1.1

# Day of Year to MATLAB date

by

### Ashley (view profile)

22 May 2009 (Updated )

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

File Information
Description

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);

Acknowledgements

Date To Decimal Day Of Year inspired this file.

This file inspired F10.7 Solar Flux & Ap Indices.

MATLAB release MATLAB 7.4 (R2007a)
25 Jul 2015 Alfonso

15 Sep 2014 D

### D (view profile)

02 Feb 2012 Liisa

### Liisa (view profile)

24 Oct 2011 alexzhao zhao

### alexzhao zhao (view profile)

06 Oct 2011 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);