# at

Syntax

at(X, [index])

Arguments

If only 1 parameter is specified: X is a Boolean expression or a vector.

If both parameters are specified: X is a scalar/vector/matrix;

index is a Boolean expression or a vector.

Details

In the first case, return the indexes of the elements of X that are true.

In the second case, return the elements in X that correspond to the elements in Y that are true. Function at is equivalent to brackets operator []. For example, “X.at(X>3) is equivalent to “X[X>3]”.

Examples

```\$ x=5 7 0 4 2 3
\$ at(x>3)
[0,1,3]
// at position 0, 1, and 3, x>3 is true.

// compare with x>3:
\$ x>3;
[1,1,0,1,0,0]

\$ x[x>3]
[5,7,4]
\$ x at x>3
[5,7,4]

\$ x=5 7 0 0 0 3
\$ at(x==0)
[2,3,4]

\$ x[x==0]
[0,0,0]

\$ shares=500 1000 1000 600 2000
\$ prices=25.5 97.5  19.2 38.4 101.5
\$ prices[shares>800]
[97.5,19.2,101.5]
\$ prices at shares>800
[97.5,19.2,101.5]

\$ m=(1..6).reshape(2:3)
\$ m;
```

0

1

2

1

3

5

2

4

6

```\$ at(m>3)
[3,4,5]

\$ m[m>3] // equal to m at m>3
```

col1

col2

col3

5

4

6

```\$ m at (0 2)  // locate column 0 and 2
```

0

1

1

5

2

6

```// compare with the following code:
\$ m at (0,2)
5
```