function [d,w] = weekday(t)
%WEEKDAY Day of week.
%   [D,W] = WEEKDAY(T) returns the day of the week in numeric and 
%   string form given T, a serial date number or a date string.  
%   The days of the week are assigned the following values.
%
%                       1     Sun
%                       2     Mon
%                       3     Tue
%                       4     Wed
%                       5     Thu
%                       6     Fri
%                       7     Sat
%
%   For example, [d,w] = weekday(728647) or [d,w] = weekday('19-Dec-1994')
%   returns d = 2 and w = Mon.
% 
%   See also EOMDAY, DATENUM, DATEVEC.
 
%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.11 $  $Date: 2000/06/01 16:09:46 $

if isstr(t)
  t = datenum(t); 
end

week = ['Sun';'Mon';'Tue';'Wed';'Thu';'Fri';'Sat'];

d = mod(fix(t)-2,7)+1;
w = week(d,:);

