[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Boolean Indexing / Fortran Indexing

**From**: |
Christoph Mecklenbraeuker |

**Subject**: |
Boolean Indexing / Fortran Indexing |

**Date**: |
Tue, 18 Jul 1995 20:39:37 +0200 (MET DST) |

Hello Francesco,
You wrote:
>* octave:2> a(a<0) = 4711*
>* error: single index only valid for row or column vector*
>* error: evaluating assignment expression near line 2, column 8*
Sorry, i forgot to tell:
There is an internal-octave-flag called ``do_fortran_indexing'',
which (if it is set to "true") allows you to perform single-index-indexing
on matrices:
Try:
>* octave:1> do_fortran_indexing = "true"*
>* do_fortran_indexing = true*
>* octave:2> a = [ -5 2; 4 7]*
>* a =*
>* -5 2*
>* 4 7*
>
>* octave:3> a(1:4)*
>* ans =*
>* -5 4 2 7*
This feature is *very* helpful in the context of boolean expressions:
(Special Thanx to John W.E.!)
>* octave:4> a(a<0) = 4711*
>* a =*
>* *
>* 4711 2*
>* 4 7*
Cheers, and all the best,
Christoph
PS: i like this do_fortran_indexing so much, that i have set this flag
to "true" in the system-wide file
/usr/local/lib/octave/1.1.0/m/startup/octaverc.
This is, why I forgot to tell you.