function weekday=dayofweek(d) % weekday=dayofweek([day month year]) % Uses Zeller's congruence to calculate the day of the % week from the date month=1+rem(d(2)+9,12); year=d(3)-fix(month/11); century=fix(year/100); year=rem(year,100); day=d(1); val=fix(2.6*month-0.2)+day+year+fix(year/4)+fix(century/4)-2*century; wday=1+rem(28+val,7); % add 28 to ensure is a +ve value in 21st century days=['Sunday ';'Monday ';'Tuesday ';'Wednesday';'Thursday ';'Friday ';'Saturday ']; weekday=days(wday,:);