
A6.8 Expressions 143
Table A6.5 Result from operators involving an empty matrix as argument.
operator either argument empty both arguments empty
== FALSE TRUE
!= TRUE FALSE
>= FALSE TRUE
> FALSE FALSE
<= FALSE TRUE
< FALSE FALSE
other <> <>
A6.8.2 Postfix expressions
A6.8.2.1 Indexing vector and array types
Vector types (that is, string or matrix) are indexed by postfixing square brackets. A
matrix can have one or two indices, a string only one. In the case of two indices, they
are separated by a comma. If a matrix has more than one row or more than one column,
two indices must be used.
Note that indexing always starts at one. So a 2 × 3 matrix has elements:
[1,1] [1,2] [1,3]
[2,1] [2,2] [2,3]
Four ways of indexing are distinguished:
indexing type example
all elements m[.,.]
scalar m[1,1]
expression z={12}; m[1,z]
element-list m[1,1:2]
• A dot selects all elements (all rows for the first index, all columns for the second).
• In the scalar indexing case (allowed for all non-scalar types), the expression in-
side square bracketsmust have scalar type, whereby double is convertedto integer
by discarding the fractional part.
If the index is scalar 0, all rows (first index) or columns (second index) are used;
all elements if one index is used on a vector.
• An expression can be used for the index. If the expression evaluates to a a scalar,
it is identical to scalar indexing. If it evaluates to a matrix, all elements will be
used for indexing.
A matrix in the first index selects rows, a matrix in the second index selects
columns. The resulting matrix is the intersection of those rows and columns.
• An index can be written as a space separated list of elements. Such elements
Komentarze do niniejszej Instrukcji