Question: MATLAB 4. (a) Write a MatLab program that uses Matlab's svitch construction to convert a date entered by the user in the form mm/dd/yyyy into
MATLAB
4. (a) Write a MatLab program that uses Matlab's svitch construction to convert a date entered by the user in the form mm/dd/yyyy into its text form (i.e., Month day, year). For example, if 02/17/2019 is entered, the program should print out "February 17, 2019". To read in a text string entered by the user, use the following form of the input statement: Date = input ('Enter date as mm/dd/yyyy: ,, ,s') The string variable Date will then be a 10-element vector, whose elements are the individual characters in the string. You can extract a piece of the string and convert it to a numeric variable using the colon operator to specify a range of elements as a vector index and the MatLab function str2num(). For example, to extract the number for the month from Date, use MonthNumber-str2num (Date (1:2)) To save typing, your program only needs to consider dates that are in the first half of the year January through June. (b) Add code to your program that prints out the number of the day in the year corresponding to the date the tse has entered. For example, if the user enters 03/12/2019, the program should print out "This is day number 71 of 2019" The number of days in each of the first six months are: Jan-31, Feb-28, Mar- 31, Apr 30, May 31, Jun-30 I need the MATLAB code for both parts please
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
