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

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'

my code is

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

what is problem?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!