I modified Easter.m to give me how many times and on what dates Easter occurs in March/April in a century. How would I use that to make a vector to check for all the dates Easter can't occur?

4 views (last 30 days)
%% This script gives how many times Easter occurs on the dates during the century.
c = zeros(1,31);
for year = 2000:2100
dn=easter(year);
fulldate=datevec(dn);
date=fulldate(3);
c(date) = c(date) + 1;
end
%% This script gives how many times Easter occurs in March/April in the century.
Easter_in_March = 0;
Easter_in_April = 0;
for y = 2000:2100 % 21 st century
g = mod(y,19) + 1;
c = floor(y/100) + 1;
x = floor(3*c/4) - 12;
z = floor((8*c + 5)/25) - 5;
e = mod(11*g + 20 + z -x, 30);
if (e == 25 && g>1 e==24)
e = e + 1;
end
n = 44 - e;
if n<21
n = n + 30;
end
d = floor(5*y/4) - x - 10;
d = n + 7 - mod(d+n,7);
if d <32
Easter_in_March = Easter_in_March + 1;
else
Easter_in_April = Easter_in_April + 1;
end
end
fprintf('in 21st Century \n%g times Easter occurs in March', Easter_in_March)
fprintf('\n%g times Easter occurs in April', Easter_in_April)

Accepted Answer

Rik
Rik on 9 Feb 2018
All the functions you use support array inputs, so you only need to change you if-statements to logical indexing (use the condition as index, after replacing double ampersand with a single one).

More 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!