From help-octave-request at che dot utexas dot edu Mon Jan 30 19:20:34 1995 Subject: Re: Zero-One indexing a length-one vector? From: John Eaton To: Keh-Cheng Chu cc: help-octave at che dot utexas dot edu Date: Mon, 30 Jan 95 19:20:29 CST Keh-Cheng Chu wrote: : In Octave, can I use zero-one indexing on a length-one vector? : I have some functions that work correctly in MATLAB but fail : in Octave when the arguments are length-one vectors. : : Here is an example: : : octave:15> b1 = [1]; b2 = [1 2]; b3 = [1 2 3]; : octave:16> b1 (b1<0), b2 (b2<0), b3 (b3<0) : ans = [](0x0) : ans = [](1x0) : ans = [](1x0) : octave:17> b2 (b2<0) = b2 (b2<0) + 1 : b2 = : : 1 2 : : octave:18> b1 (b1<0) = b1 (b1<0) + 1 : error: invalid index = 0 : error: evaluating assignment expression near line 18, column 11 This bug is fixed in my sources and should not appear in version 1.1.1, which I plan to release soon. : One related (?) question that I have is this: : : Why is b1(b1<0) a [](0x0) and not a [](1x0) or a [](0x1)? After : all, b1 can be either a row or a column vector, so why isn't : one of the dimensions of the empty matrix 1? I don't know. I suppose `prefer_column_vectors' could be used to determine the result. Hmmm. jwe