help-octave
[Top][All Lists]
Advanced

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

new functionality with '[]'?


From: Mike Miller
Subject: new functionality with '[]'?
Date: Wed, 21 Sep 2005 19:20:11 -0500 (CDT)

On Wed, 21 Sep 2005, Henry F. Mollet wrote:

This is curious as I thought this was in my ancient Octave manual. I fired up 2.1.46 on old iMac and below worked just fine.

OK. I did make a mistake in giving an "example" that was different from the code that produced an error. Your method of deleting rows even works with "GNU Octave, version 2.0.14 (sparc-sun-solaris2.6)," which truly is ancient. The thing that doesn't work on older versions is this:

X=rand(3);
X(1)=[]
error: A(I) = X: X must be a scalar or a matrix with the same size as I
error: assignment failed, or no method for `matrix = matrix'
error: evaluating assignment expression near line 12, column 5

That fails in...

GNU Octave, version 2.1.50 (i686-pc-linux-gnu)

...but it works in...

GNU Octave, version 2.1.71 (i686-pc-cygwin).

It might have to do with do_fortran_indexing.  This is from 2.1.71:

octave:1> X=rand(3)
X =

  0.45610  0.32443  0.34168
  0.51433  0.13733  0.84220
  0.64126  0.85705  0.46983

octave:2> X(1,1)=[]
X =

  0.45610  0.32443  0.34168
  0.51433  0.13733  0.84220
  0.64126  0.85705  0.46983

octave:3> X(1)=[]
X =

  0.51433  0.64126  0.32443  0.13733  0.85705  0.34168  0.84220  0.46983

That version doesn't use do_fortran_indexing. The older version does use it, and this is what it does with the code:

octave:14> X=rand(3)
X =

  0.429064  0.059207  0.106101
  0.649472  0.144184  0.388475
  0.379600  0.035778  0.577756

octave:15> do_fortran_indexing
do_fortran_indexing = 1
octave:16> X(1)=[]
error: A(I) = X: X must be a scalar or a matrix with the same size as I
error: assignment failed, or no method for `matrix = matrix'
error: evaluating assignment expression near line 16, column 5
octave:16> X(1,1)=[]
X =

  0.429064  0.059207  0.106101
  0.649472  0.144184  0.388475
  0.379600  0.035778  0.577756


Mike



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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