# [index]

Index function.

## Syntax

expr [index_1] [index_2]

## Operands

expr
A valid vector, matrix, string, or string array expression.
index_1
Either a scalar expression that describes the position of an element in a vector or vector expression that describes the position of a row of elements in a matrix.
index_2
An optional scalar or vector expression that describes the position of an element of a matrix.

## Example

Table 1. Templex Expressions
Expression Result
a = {4, 2, 6, 8}

a[2]

6
{1, 2, 3, 4} [0] 1
{2, 4, 6, 8} [{1, 2}] {4,6}
{ {1, 2, 3,}, {4, 5, 6} } [1] {4, 5, 6}
{ {1, 2, 3,}, {4, 5, 6} } [1] [0] 4
{"The ", "quick ", "brown ", "fox"} [2] "brown"
Table 2. Curve Math Vectors
Expression Result
x = c1.x[0:100:1]

y = c1.y[0:100:1]

A curve is created which is the first 101 points of c1.
A range is used to specify index_1.

[index] is the only mathematical function where brackets, [ ], do not indicate optional items. The brackets are part of this function's syntax.

The index function accesses specific elements of a vector or matrix expression.

The first element of a vector is at index zero. index_1 and index_2 must be non-negative and less than the total number of elements in the vector expression.

If expr is a vector, the result is the scalar located at the index_1 position.

If expr is a matrix, the result is the row vector located at the index_1 position. A second index can be used to identify the scalar at the index_2 position of the index_1 vector.

If expr is a string array, the result is the string located at the index_1 position. A second index cannot be used to identify characters within the string array.