MATLAB: Hey guys, I am really lost and I don’t know where to start with this question

Write a function called year2016 that returns a row-vector of struct-s whose elements correspond to the days of a month in 2016 as specified by the input argument. If the input is not an integer between 1 and 12, the function returns the empty array. Each struct should contain three fields with these (exact) field names: “month”, “date”, and “day” (all lower case).  The month field must contain a string with the name of the month (first letter capitalized).  The date field must contain a scalar specifying the day of the month.  The day field must contain the three-letter abbreviation of the day chosen from this list: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'. For example, here is a call of the function followed by a command that shows the seventh element of the struct array that is returned by the function: >> m = year2016(2); >> m(7) ans = month: 'February' date: 7 day: 'Sun'
I have been trying for hourse. I am not sure how to make it so, that when i call the function afther that i have the option to write m again but this time give it a value and to become the day at the end. I would be really gratefull. It should look like this :
m = year2016(4)
m =
1×30 struct array with fields:
month
date
day
>> m(1)
ans =
struct with fields:
month: 'April'
date: 1
day: 'Fri'
and myone one looks like this:
m = year2016(1)
m =
struct with fields:
month: 'January'
day: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31]
Here is my code now, i have changed it more than 10 times so it doesnt really show my closest attempt probably, but would give some idea why i am not doing it right.
function [m] = year2016( x )
field1 = 'month'; field2 = 'date'; field3 = 'day';
m1 = 'January'; m2 = 'February'; m3 = 'March';
m4 = 'April'; m5 = 'May'; m6 = 'June';
m7 = 'July'; m8 = 'Augustm'; m9 = 'September';
m10 = 'October'; m11 = 'November'; m12 = 'December';
d1 = {1,2,3}; d2 = [1:30]; d3 = [1;2;3];
m = struct(field1,m1,field2,d3);
%,m2,d1,m3,d3,m4,d2,m5,d3);
end

Best Answer

This code does the job (copied from my answer to this question, so this code is already in the public domain)
function out = year2016(m)
VN = datenum([2016,m,1]):datenum([2016,m+1,1])-1;
DN = 1+mod(VN-3,7);
MC = {'January';'February';'March';'April';'May';'June';'July';'August';'September';'October';'November';'December'};
DC = {'Mon','Tue','Wed','Thu','Fri','Sat','Sun'};
out = struct('day',DC(DN),'date',num2cell(1:numel(VN)));
[out(:).month] = deal(MC{m});
end
And tested:
>> m = year2016(12); m(8)
ans =
day = Thu
date = 8
month = December
>> m = year2016(1); m(1)
ans =
day = Fri
date = 1
month = January
>> m = year2016(2); m(29)
ans =
day = Mon
date = 29
month = February
>> m = year2016(4); m(1)
ans =
day = Fri
date = 1
month = April