That's not the correct usage of datevec and datestr.
The first thing you need to do is work out how many days are in that year (ie leap year or not). Then it's just a matter of adding the fractional days multiplied by the number of days in the year to the julian day at the beginning of the year.
Just use MatLab's date numbers for flexibility. The following function should convert your serial year to a MatLab date:
function [num] = ConvertSerialYearToDate( y )
year = floor(y);
partialYear = mod(y,1);
date0 = datenum(num2str(year),'yyyy');
date1 = datenum(num2str(year+1),'yyyy');
daysInYear = date1 - date0;
num = date0 + partialYear * daysInYear;
end
And then you can use datevec to split that into its components, or datestr to turn it into a string, etc.
-g-
Best Answer