Prev: spmd help
Next: LIBSVM and Visual Studio 2010
From: Jan Simon on 29 Jun 2010 20:07 Dear readers, This fails in Matlab 2009a: n = datenum(datestr(now, 30), 30) with the message: Failed to lookup month of year. The other formats are working, e.g. n = datenum(datestr(now, 29), 29) I cannot find this in the bugreports: http://www.mathworks.com/support/bugreports Am I searching correctly?? Is this still buggy in 2010a? Kind regards, Jan
From: Steven Lord on 29 Jun 2010 23:30 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message news:i0e1r8$c5m$1(a)fred.mathworks.com... > Dear readers, > > This fails in Matlab 2009a: > n = datenum(datestr(now, 30), 30) > with the message: > Failed to lookup month of year. Use this instead: datenum(datestr(now, 30), 'yyyymmddTHHMMSS') > The other formats are working, e.g. n = datenum(datestr(now, 29), 29) I'm pretty sure that the reason it works is not the reason you think it does. Let's look at the documentation for DATENUM. http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datenum.html When you use the datenum(..., 30) or datenum(..., 29) cases you _think_ you're using the datenum(S, F) syntax, right? Well, 29 and 30 are not strings so I'm pretty sure you're using the datenum(S, P) syntax [which is related to the datenum(S) syntax] instead. I also believe that the comment that says that only strings in specified formats may be used is out-of-date and that format 29 may be acceptable for the datenum(S) syntax as well. [I'll check this with the developers.] Now how does NOW look in date format 29? >> datestr(now, 29) 2010-06-29 Since the year is expressed using 4-digits, when you try to convert that back into a date number there's no need for the pivot year. That's why your second example worked. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Matt Fig on 29 Jun 2010 23:31 I'm using 2007b: cnt = 1; for ii = 1:30 try datenum(datestr(now,ii),ii); catch er(cnt) = ii; cnt = cnt+1; end end er = 3 4 5 7 8 9 10 11 17 18 27 30 17,18 and 27 I expect from the doc. But this would seem to indicate the rest should work: "Certain formats may not contain enough information to compute a date number. In these cases, hours, minutes, seconds, and milliseconds default to 0, the month defaults to January, the day to 1, and the year to the current year."
From: TideMan on 29 Jun 2010 23:32 On Jun 30, 12:07 pm, "Jan Simon" <matlab.THIS_Y...(a)nMINUSsimon.de> wrote: > Dear readers, > > This fails in Matlab 2009a: > n = datenum(datestr(now, 30), 30) > with the message: > Failed to lookup month of year. > > The other formats are working, e.g. > n = datenum(datestr(now, 29), 29) > > I cannot find this in the bugreports: > http://www.mathworks.com/support/bugreports > Am I searching correctly?? > Is this still buggy in 2010a? > > Kind regards, Jan But it fails in my old version 2006a as well, so there's nothing new here. Not that I would ever use format no 30 - weird bloody format it has.
From: Jan Simon on 30 Jun 2010 02:44
Dear Steven, > > This fails in Matlab 2009a: > > n = datenum(datestr(now, 30), 30) > Use this instead: > datenum(datestr(now, 30), 'yyyymmddTHHMMSS') Thanks, you solved my confusion. Digging in the -let me tell it- voluminous code of DATENUM (which calls DATEVEC, which calls DATEUM again) for my problem confirmed, that I've misunderstood the documentation. DATENUM cannot be called with a numerical specifier for the input format, although it can sometimes produce the correct answer. Thanks Matt and TideMan. The behaviour was not new, but it did not equal my expectations and I assume, that even an old bug could be a bug. Kind regards, Jan |