Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


dpb
Posts:
8,982
Registered:
6/7/07


Re: Ismember/intersect not possible with serial date numbers?
Posted:
Mar 5, 2013 7:17 PM


On 3/5/2013 6:07 PM, Vegard wrote: > TideMan <mulgor@gmail.com> wrote in message <ebb90dc86be04678a0fc >> >> If you're finding that "strange", then you don't understand/haven't >> read the FAQ. >> Look at this: >> >> format long >> >> 1/24/60 >> >> ans = >> >> 6.944444444444444e004 >> This is the increment you are using in generating year_serial1. >> Clearly, there will be roundoff error because of all those digits. >> > > I'm sorry  I should have been more clear; what puzzled me about the > example in my previous post was how the last two commands were able to > fix the roundoff errors introduced by the first three. Apparently, the > datevec function is quite clever.
Well, when you passed it the dateserial numbers that were off by 1 LSB it rounded to nearest integer and that cleans up the "fuzz" by returning the input to the next call to datenum() that you made to exact integers.
datenum() is, as shown in my example, very clever indeed...
> Thank you both for taking the time to answer in detail. I didn't fully > understand what you meant in your first reply, dpd, but it is clear to > me now. I certainly read the FAQ, and the Cleve's corner that was linked > to from there, and I've learned some important stuff about floating > point arithmetic!
I didn't say it as well as could have perhapsI sorta' presumed that the "using datenum consistently" would get through but it's easy to see why that wasn't necessarily enough detail to get you over your hurdle given what you had done (which is reasonableenough on the face of it until one realizes what you've now learned).
Good on the latter...if you haven't yet found it (I forget for sure but I think there's perhaps a link in the FAQ) DAGS on "What Every Computer Scientist..." and Goldberg for a very nice paper on the details of the subject. Even if you don't study it thoroughly now, knowing it's there when you need it can be priceless...




