dpb <email@example.com> wrote in message <firstname.lastname@example.org>... > On 7/9/2013 9:24 PM, TideMan wrote: > > On Wednesday, July 10, 2013 1:20:34 PM UTC+12, dpb wrote: > ... > > And with floating point numbers, shouldn't it be: > > DNZmin=min(abs(D(abs(D)>tol))); > > where tol is a small number like 1e-6 > > ... > > If in the original code the lambda in the comparison were some other fp > value, then your recommendation/concern is right on. But in the actual > code lambda is min() of of the same vector so it's identical by that > process of selection already and the existence of a value off by only > LSB in the mantissa if it were to exist is already out, anyway. But the > missed comparison of a value entered at the keyboard trying to compare > to one computed internally as is so often the cause of the FAQ question > doesn't arise here. > Isn't TideMan right? The inner parenthesis comparison, D~=0, is comparing floating point numbers in D to 0. If there is a very, very small value of D, say 1e-20, which really should be zero, I don't want that value returned. In your case, since I didn't specify how D was created, shouldn't you have included that?
FYI: D is created as follows: for jj = 1:N for kk = 1:N idxVal = (jj-1)*N + k; D(idxVal)=4-2*cosd((jj*180)/(N+1)) - 2*cosd((kk*180)/(N+1)); end end
N is an integer, power of 2, at least 8 (e.g., 8, 16, 32,...). I'm pretty sure I can get away with D~=0, but I'm curious how you knew that without knowing D.