select
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
Conditional merge of selected elements of two vectors and/or scalars.
- Usage
select(x, t, yl, yh)
- x
- condition vector; must be a vector!
- t
- threshold
- yl
- result if
x[i] <= t{[i]}
- yh
- result if
x[i] > t{[i]}
- t, yl and yh must be numbers or vectors with the same length as x
- Result
- A vector r with ...
r[i] = yl{[i]}
if x[i] <= t{[i]} and
r[i] = yh{[i]}
if x[i] > t{[i]}
- The result r has the same length as x.
Example:
#a := eval vv(1,2,3,4,5)
#b := eval vmcol($#a, vv(5,4,3,2,1))
#c := vsubc($#a,0,3)
// -> vector: $#c = { 1 , 2 }
#d := eval vsubc($#a,2,0,5,$#b)
// -> matrix: $#d[*,0] = { 2 , 3 , 4 }, $#d[*,1] = { 4 , 3 , 2 }
#e := eval vsubc($#a,7,2,4)
// -> vector: $#e = { 1 , 2 , 4 , 5 }