octave-maintainers
[Top][All Lists]
Advanced

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

subscripted assignment to logical


From: John W. Eaton
Subject: subscripted assignment to logical
Date: Tue, 17 May 2005 12:58:54 -0400

Matlab apparently behaves like this:

  x = eye (3);  %% any matrix

  x(2,3) = y;   %% Y == any 1 or 0 value, no warning, X remains logical
  x(2,3) = z;   %% Z == any other value, a warning, X remains logical

Should we also adapt this behavior for Octave?  Currently, Octave
converts X to the wider type of the RHS.

We already have a similar case for the integer types.  For example, we
have

  octave:1> x = uint8 (eye (3))
  x =

    1  0  0
    0  1  0
    0  0  1

  octave:2> class (x)
  ans = uint8
  octave:3> x(2,2) = 32423
  x =

      1    0    0
      0  255    0
      0    0    1

  octave:4> class (x)
  ans = uint8

In this case, Octave works the same as Matlab, though Matlab offers
some optional warnings about conversions that Octave does not yet
have.

jwe



reply via email to

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