MATLAB: Function that transforms years into days

days to years

Hello. How do I write function to transform years into days?

Best Answer

Like this?
function numDay = year2days(year)
numDay = days(datetime(year,12,31)-datetime(year,1,1))+1;
end
The following is one example:
>> year2days(2000)
ans =
366