Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

What are the classifications of Bank?

Answered: 1 week ago