MATLAB: Convert day of year to Date

datedatetimedayofyearmonthtimeyear

I want help converting 1 to 1st Jan; 365 to 31st Dec and so on. Basically I want to convert day number of a year into the actual date it corresponds to. Any help will be greatly appreciated. I have done the inverse using the following code
d = datetime('20-Mar-2018')
Dn = day(d,'dayofyear')

Best Answer

I finally found the answer I was looking for.
N=10; %you can input any other number,The day in question is the 'N'th day of the year
Dt=datetime('1-Jan-2018')+N-1 % This code will give the date of the 'N'th day.