syntax of find
Thorsten Meyer
thorsten.meyier at gmx.de
Sat Jun 6 16:34:45 CDT 2009
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
More information about the Octave-maintainers
mailing list