%% daymon.m determines the number of days in the given
%% month of the year.
%%

function dayt=daymon(month,year)

% month = month of year
% year = year
% dayt = number of days in month

sz=size(month);                                   %size of input
month=month(:);                                   %convert input to column vector
year=year(:);
dayv=[31 28 31 30 31 30 31 31 30 31 30 31];
dayt=dayv(month);
lyc=rem(year,400)==0 | (rem(year,4)==0 & rem(year,100)~=0);     %check if leap year

%Check for leap year
if any(lyc & month==2)
 dayt(lyc & month==2)=29;
end

dayt=reshape(dayt,sz);