Programmer Guide/Command Reference/EVAL/vsubc: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 15: Line 15:
::;''c''=2: select all rows ''i'' where <code>''vmin'' < '' ''x''[''i''] < ''vmax''</code>
::;''c''=2: select all rows ''i'' where <code>''vmin'' < '' ''x''[''i''] < ''vmax''</code>
::;''c''=3: select all rows ''i'' where <code>''x''[i] <= ''vmin'' or ''x''[''i''] >= ''vmax''</code>
::;''c''=3: select all rows ''i'' where <code>''x''[i] <= ''vmin'' or ''x''[''i''] >= ''vmax''</code>
:If a boundary ''vmin''/''vmax'' is a vector, the i-th element of the vectors ''x'' and ''vmin''/''vmax'' are compared, otherwise the element  ''x''[''i''] is compared with the number ''vmin''/''vmax''.
:If a boundary ''vmin''/''vmax'' is a vector, the i-th element of the vectors ''x'' and ''vmin''/''vmax'' are compared, otherwise the element  ''x''[''i''] is compared with the number ''vmin''/''vmax''. The function failes, if no row is selected.


;See also: [[Programmer_Guide/Command_Reference/EVAL/vsubn|vsubn]], [[Programmer_Guide/Command_Reference/EVAL/select|select]], [[Programmer_Guide/Command_Reference/EVAL/vvset|vv]]
;See also: [[Programmer_Guide/Command_Reference/EVAL/vsubn|vsubn]], [[Programmer_Guide/Command_Reference/EVAL/select|select]], [[Programmer_Guide/Command_Reference/EVAL/vvset|vv]]

Revision as of 10:02, 6 April 2011


Extract rows from a vector or matrix.

Usage
vsubc(x , 0 , vmin {, y }})
vsubc(x , 1 , vmax {, y }})
vsubc(x , 2 , vmin, vmax {, y }})
vsubc(x , 3 , vmin, vmax {, y }})
x
condition vector (and source vector if argument y is not supplied); must be a vector!
vmin
lower boundary; must be a scalar or a vector with the same length as x
vmax
upper boundary; must be a scalar or a vector with the same length as x
y
optional source data; must be a vector or matrix with the same number of rows as x
Result
A numerical object consisting of all selected rows of the source y (or x if y is not supplied). The 2nd argument c must be a number in the range 0 to 3 and defines the condition used for the selection of the source rows.
c=0
select all rows i where x[i] < vmin
c=1
select all rows i where x[i] > vmax
c=2
select all rows i where vmin < x[i] < vmax
c=3
select all rows i where x[i] <= vmin or x[i] >= vmax
If a boundary vmin/vmax is a vector, the i-th element of the vectors x and vmin/vmax are compared, otherwise the element x[i] is compared with the number vmin/vmax. The function failes, if no row is selected.
See also
vsubn, select, vv

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 }

<function list>

Navigation menu

Personal tools