A formula, called Zeller\'s Congruence, may be used to compute the day of the we
ID: 3573149 • Letter: A
Question
A formula, called Zeller's Congruence, may be used to compute the day of the week, given the date (within a certain rang dates). The formula Is given below: f = 1 + ([2.6 m - 0.2] + k + y + [y/4] + [c/4] - 2 c)modulo 7 where the square brackets denote the integer part, modulo 7 means the remainder when divided by 7, and m = the month number, with January and February taken as months 11, 12 of the preceding year, so March is then month 1, and December month 10; k = the day of the month; c = the century number; y = the year in the century; f = 1 means Sunday, 2 means Monday, etc For example 23^rd August 1963 is represented by m = 6, k = 23, c = 19, y = 63; 1st January 1800 is represented by m = 11, k = 1, c = 17, y = 99. Write a function dayofweek(d) which takes the date in the form of a vector d = [dd mm yyyy] (e.g. [9 3 2001] for March 9, 2001 and returns the day of the week (in words) on which it falls. Test your program on some known dates, like today's date, or your birthday.Explanation / Answer
% Matlab script to calculate day
% using Zeller's congruence
% usage :
% weekday=dayofweek([day month year])
--------------------------------------------------------------------
Sample output:
--> dayofweek([6,12,2016])
ans =
Tuesday
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.