Clear Filters
Clear Filters

When is Easter?Plot a bar graph of the dates of Easter during the 21-st century.

4 views (last 30 days)
well ,the Easter occur 22 in March ,and 78 in April during the 21-st century . but I don't know how to solve those question .
  • Plot a bar graph of the dates of Easter during the 21-st century.
  • How many different dates does can Easter occur ?
  • What's the earliest in the year ?what's the latest ?
  • Is the date of Easter a periodic function of the year number ?
function bar4easter
f=zeros(1,100);
y=2000;
for k=1:100
f(k)=easter(y);
y=y+1;
end
[~,m,d,~,~,~]=datevec(f);
count3=0;
count4=0;
for k=1:100
if m(k)==3
count3=count3+1;
else
count4=count4+1;
end
end
count3
count4
hist(m)
and this is Easter.m below .
function dn = easter(y)
% EASTER Date of Easter.
% EASTER(y) is the datenum of Easter in year y.
% Ref: Donald Knuth, The Art of Computer Programming,
% Fundamental Algorithms, pp. 155-156.
% Golden number in 19-year Metonic cycle.
g = mod(y,19) + 1;
% Century number.
c = floor(y/100) + 1;
% Corrections for leap years and moon's orbit.
x = floor(3*c/4) - 12;
z = floor((8*c+5)/25) - 5;
% Epact.
e = mod(11*g+20+z-x,30);
if (e==25 && g>11 || e==24), e = e + 1; end
% Full moon.
n = 44 - e;
if n < 21, n = n + 30; end
% Find a Sunday.
d = floor(5*y/4) - x - 10;
% Easter is a Sunday in March or April.
d = n + 7 - mod(d+n,7);
dn = datenum(y,3,d);

Answers (0)

Categories

Find more on Holidays / Seasons in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!