From: Walter Roberson on 23 Jun 2010 18:18 Doug Weathers wrote: > The function WEEKDAY appears to reduce to the formula > > weekday = mod(datenum-2, 7) + 1; How could that take care of leap years?? > while HOLIDAYS merely contains a long list of date numbers for New York > Stock Exchange holidays from 1950 to 2050. It returns the holidays > between the given datenums. > To reproduce it, you could type in a list of your particular holidays > from a calendar into a vector, then check to see if your datenum is a > member of that set with ISMEMBER. You would probably want to fix() the datenum before doing ismember so that the fractions of a day don't throw you off.
From: Loren Shure on 24 Jun 2010 07:14 In article <9e358331-2765-4d86-a871-a93eb8bdc3b5 @b5g2000vbl.googlegroups.com>, lunamoonmoon(a)gmail.com says... > It's like this: > > Today is 6/22/2010, last year's today is 6/22/2009, and today 2 years > agoo is 6/22/2008. > > This is simple to do in Matlab. > > How about what about business days and weekend...? > > I am looking for something like today in last year... > > but if that was a weekend or holiday, > > then I would like the date before that and the date after that. > > How to do this in Matlab? > > Thanks > Check this out for a start: http://blogs.mathworks.com/loren/2010/06/11/simple-date-manipulations/ -- Loren http://blogs.mathworks.com/loren http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Doug Weathers on 24 Jun 2010 13:32 Walter Roberson <roberson(a)hushmail.com> wrote in message <hvu1bm$i9o$1(a)canopus.cc.umanitoba.ca>... > Doug Weathers wrote: > > > The function WEEKDAY appears to reduce to the formula > > > > weekday = mod(datenum-2, 7) + 1; > > How could that take care of leap years?? By ignoring them :) Weekdays keep cycling from Sunday to Saturday without regard to the date. That's why the simple formula above works all the way back to day zero (1-1-0000). > > You would probably want to fix() the datenum before doing ismember so that the > fractions of a day don't throw you off. Of course I ignored all error checking for the sake of the example. By all means, validate your input!
First
|
Prev
|
Pages: 1 2 Prev: VisualStudio RTW Compiler Configuration Next: Data Acquisition and Windows 7 UAC |