octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax of find


From: Jaroslav Hajek
Subject: Re: syntax of find
Date: Sun, 7 Jun 2009 08:21:15 +0200

On Sat, Jun 6, 2009 at 11:34 PM, Thorsten Meyer<address@hidden> wrote:
> In the documentation of cs-lists I find the following example:
>
> x = ceil (randn (10, 1));
> in = struct ("call1", {x, Inf, "last"},
>             "call2", {x, Inf, "first"});
> out = struct ("call1", cell (2, 1), "call2", cell (2, 1));
> [out.call1] = find (in.call1);
> [out.call2] = find (in.call2);
>
> With the current tip, it fails, because octave tries to allocate for an
> infinitely large return vector. I guess, that at some point, "inf" as the 
> second
> input argument to find meant "all". By experimenting, I found that giving a
> negative number (or even -inf) instead of Inf will find all nonzero elements 
> now.
>
> Is that compatible behaviour?
>
> What does matlab say to
>
> find([1, 0, 1, 0, 1], -1, "last")
>
> and
>
> find([1, 0, 1, 0, 1], inf, "last")
>
> ?
>
> Thanks
>
> Thorsten
>
>

Hmm. It seems at a certain point I missed the crucial fact that the
second arg to find gives a *maximum* number of indices, which is not
mentioned in the docs (although it's quite logical).
The docs were also misleading in that they said that "last" forces
"counting from the last one", which IMHO implies that the last index
should come first, which was apparently not true in 3.0.x (but is in
3.2.0).
Both bugs are fixed now, and docs improved.

thanks


-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]