a Write a script that prompts the user to input the day mont
a) Write a script that prompts the user to input the day, month, and year; determine the day of the year (the number of days including the current day). Be sure to take leap year into account. Use a for loop Test your code on the following dates February 28, 2015 April 9, 1976 October 12, 1887 b) Create a script that performs the same function as repmat. The only built-in commands you may use are input, size, and disp
Solution
(a)
MATLAB code
clear all;
close all;
clc
day=input(\'Enter day : \',\'s\');
mnth=input(\'Enter month : \',\'s\');
year=input(\'Enter year : \',\'s\');
tdate=strcat(day,\'-\',mnth,\'-\',year);
DayForm = \'long\';
[DayNumber,DayName] =weekday(tdate,DayForm);
disp(\'The day of the year is \')
fprintf(\'%s\ \',DayName);
sample outputs
Enter day : 28
Enter month : February
Enter year : 2015
The day of the year is
Saturday
>>
Enter day : 9
Enter month : April
Enter year : 1976
The day of the year is
Friday
>>
Enter day : 12
Enter month : October
Enter year : 1887
The day of the year is
Wednesday
>>
(b)
