WHERE

Syntax: | `vout = WHERE(vector)`

The `WHERE` function only accepts a vector as argument. It returns the indices where this vector is not equal to zero.

Examples

Suppose you have a vector `X = [-5:5]` and you enter `Y=WHERE(X>0)`, then `Y` would be `[7;8;9;10;11]` since `X[Y] > 0`. If you enter `Y=WHERE(X<=0)` then `Y` would be `[1;2;3;4;5;6]` since `X[Y] ≤ 0`.

Suppose you have two vectors `X` and `Y` and you want to graph only those points that lie within the unit circle, that is, only those points that satisfy `SQRT(X2+Y2) ≤ 1`. The following commands produce the picture below.

     GENERATE/RANDOM X -2 2 10000
     GENERATE/RANDOM Y -2 2 10000
     SET PLOTSYMBOL -17
     SET %PLOTSYMBOLSIZE 0.5
     SET AUTOSCALE COMMENSURATE
     IDX=WHERE(SQRT(X^2+Y^2)<=1)
     GRAPH X[IDX] Y[IDX]