Nigel Dodd
2011-02-19 19:41:03 UTC
In one of the references about Octave it says
A special form of indexing may be used to select elements of a matrix or vector. If the indices are vectors made up of only ones and zeros, the result is a new matrix whose elements correspond to the elements of the index vector that are equal to one. For example,
a = [1, 2; 3, 4];
a ([1, 0], :)
selects the first row of the matrix a.
However when I do this I get the following error:
octave-3.2.4:1> a = [1, 2; 3, 4];
octave-3.2.4:2> a ([1, 0], :)
error: subscript indices must be either positive integers or logicals.
Has the zero-one indexing facility been removed in newer versions of Octave? Is there any workaround?
A special form of indexing may be used to select elements of a matrix or vector. If the indices are vectors made up of only ones and zeros, the result is a new matrix whose elements correspond to the elements of the index vector that are equal to one. For example,
a = [1, 2; 3, 4];
a ([1, 0], :)
selects the first row of the matrix a.
However when I do this I get the following error:
octave-3.2.4:1> a = [1, 2; 3, 4];
octave-3.2.4:2> a ([1, 0], :)
error: subscript indices must be either positive integers or logicals.
Has the zero-one indexing facility been removed in newer versions of Octave? Is there any workaround?