From bug-octave-request at bevo dot che dot wisc dot edu Thu May 17 15:59:32 2001 Subject: logical indexing problem From: "John W. Eaton" To: Adam Kornick Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 17 May 2001 15:59:25 -0500 On 17-May-2001, Adam Kornick wrote: | Bug report for Octave 2.1.33 configured for %OCTAVE_CANONICAL_HOST_TYPE% | | Description: | ----------- | | * Logical indexing does not work as described in the manual. It | only works if the last and first elements (at least) are non-zero. | | Repeat-By: | --------- | | * The following example (from | http://www.octave.org/doc/octave_9.html#SEC65 ) should produce the | first row of a, instead... | | >> a = [1, 2; 3, 4]; | >> a ([1, 0], :) | error: invalid row index = 0 The manual is out of date. Logical indexing only works now when the index is a logical objects. Try octave2.1:1> a = [1, 2; 3, 4]; octave2.1:2> a(logical ([1,0]), :) ans = 1 2 instead. Most of the time, the logical() conversion is not needed because the index is the result of some kind of comparison or boolean operation, and already has the correct type. jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------