help-octave
[Top][All Lists]
Advanced

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

Logical indexing and Octave manual example


From: Tim Largy
Subject: Logical indexing and Octave manual example
Date: Wed, 5 Mar 2008 19:02:42 -0500

I'm having trouble understanding an example in section 4.4 "Logical
Values" of the Octave manual
(http://www.gnu.org/software/octave/doc/interpreter/Logical-Values.html#Logical-Values).
The manual has:

     data = [ 1, 2; 3, 4 ];
     idx = (data <= 2);
     data(idx)
          => ans = [ 1; 4 ]

However my Octave version 2.1.73 (i686-pc-cygwin) returns a different result:

    octave:72>  data = [ 1, 2; 3, 4 ];
    octave:73>  idx = (data <= 2);
    octave:74>  data(idx)
    ans =

       1
       2

In neither case can I understand the underlying logic. The value of
idx is [1, 1; 0, 0]. What rules determine how a matrix such as this is
used in logical indexing?

Regards,

Tim Largy


reply via email to

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