The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Replacing `find` with logical indexing
Replies: 6   Last Post: Jul 10, 2013 1:47 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 113
Registered: 11/22/09
Re: Replacing `find` with logical indexing
Posted: Jul 10, 2013 10:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

dpb <> wrote in message <krikfe$o13$>...
> 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));

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.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.