Code covered by the BSD License  

Highlights from
Day of Year to MATLAB date

5.0

5.0 | 3 ratings Rate this file 31 Downloads (last 30 days) File Size: 1.68 KB File ID: #24235

Day of Year to MATLAB date

by Ashley

 

22 May 2009 (Updated 22 May 2009)

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

| Watch this File

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

The author wishes to acknowledge the following in the creation of this submission:
Date to Decimal Day of Year

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
06 Oct 2011 Salman

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

24 Oct 2011 alexzhao zhao  
02 Feb 2012 Liisa  
Please login to add a comment or rating.
Updates
22 May 2009

fixed typo in title

Tag Activity for this File
Tag Applied By Date/Time
date Ashley 22 May 2009 14:06:30
day of year Ashley 22 May 2009 14:06:30
doy Ashley 22 May 2009 14:06:30
time Ashley 22 May 2009 14:06:30
convert Ashley 22 May 2009 14:06:30
clock Ashley 22 May 2009 14:06:30
year Ashley 22 May 2009 14:06:30
julian Ashley 22 May 2009 14:06:30

Contact us at files@mathworks.com