File Exchange

image thumbnail

Day of Year to MATLAB date

version 1.1.0.0 (1.68 KB) by Ashley
Converts a day of year number and a year to a date in MATLAB format

6 Downloads

Updated 22 May 2009

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)

defsdf dfe

Alfonso

D

Liisa

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

Updates

1.1.0.0

fixed typo in title

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux