In: Mechanical Engineering
In matlab.write a program that converts a numerical date given by the user into a month, day, and year. Specifically, the user should input a sequence of eight numbers 05141956.
the program should print out the same date in complete format. In this example it would print "The date is May 14th, 1956". Notice the "th" addition after the day. This changes depending on the number. Make sure this feature is included. MATLAB has built-in date conversion functions. You cannot use them in this exercise.
NumericDate = input('Enter 8 digit Numeric Date: ','s')
monthNumber= substr(NumericDate,1,2)
if (monthNumber=='01')
MonthName='January'
elseif (monthNumber=='02')
MonthName='February'
elseif (monthNumber=='03')
MonthName='March'
elseif (monthNumber=='04')
MonthName='April'
elseif (monthNumber=='05')
MonthName='May'
elseif (monthNumber=='06')
MonthName='June'
elseif (monthNumber=='07')
MonthName='July'
elseif (monthNumber=='08')
MonthName='August'
elseif (monthNumber=='09')
MonthName='September'
elseif (monthNumber=='10')
MonthName='October'
elseif (monthNumber=='11')
MonthName='November'
else
MonthName='December'
end
Year = substr(NumericDate,5,4)
Day = substr(NumericDate,3,2)
Date = strcat(MonthName,' ',Day,'th, ',Year)