function d = eomday(y,m)
%EOMDAY End of month.
%   D = EOMDAY(Y,M) returns the last day of the month for the given
%   year, Y, and month, M. 
%   Algorithm:
%      "Thirty days hath September, ..."
%
%   See also WEEKDAY, DATENUM, DATEVEC.

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.10 $  $Date: 2000/06/01 16:09:47 $

% Number of days in the month.
dpm = [31 28 31 30 31 30 31 31 30 31 30 31]';

% Make result the right size and orientation.
d = y - m;

d(:) = dpm(m);
d((m == 2) & ((rem(y,4) == 0 & rem(y,100) ~= 0) | rem(y,400) == 0)) = 29;
