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

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 2: Line 2:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
Extract rows from a vector or matrix.
Extract rows from a vector or matrix.
;Usage: '''<code>vsubc(<var>x</var> , <var>c</var> , <var>v</var> {, <var>y</var> }})</code>''' with ''c'' = 0, 1, 4 or 5</code>
;Usage: '''<code>vsubc(<var>x</var> , <var>c</var> , <var>v</var> {, <var>y</var> }})</code>''' with ''c'' = 0, 1, 4 or 5
::'''<code>vsubc(<var>x</var> , 2 , <var>v<sub>1</sub></var>, <var>v<sub>1</sub></var> {, <var>y</var> }})</code>''' with ''c'' = 2, 3, 6 or 7
::'''<code>vsubc(<var>x</var> , 2 , <var>v</var><sub>1</sub>, <var>v</var><sub>2</sub> {, <var>y</var> }})</code>''' with ''c'' = 2, 3, 6 or 7
:;<var>x</var>: condition vector (and source vector if argument ''y'' is not supplied); must be a vector!
:;<var>x</var>: condition vector (and source vector if argument ''y'' is not supplied); must be a vector!
:;<var>v, v<sub>1</sub>, v<sub>2</sub></var>: lower and/or upper boundary; must be a scalar or a vector with the same length as ''x''
:;<var>v, v<sub>1</sub>, v<sub>2</sub></var>: lower and/or upper boundary; must be a scalar or a vector with the same length as ''x''
Line 12: Line 12:
!value of ''c'' !!row ''i'' is selected if ...
!value of ''c'' !!row ''i'' is selected if ...
|-
|-
|'''0''' ||<code>''x''[''i''] < ''vmin''</code>
|'''0''' ||<code>''x''[''i''] < ''v''</code>
|-
|-
|'''1''' ||<code>''x''[''i''] > ''vmax''</code>
|'''1''' ||<code>''x''[''i''] > ''v''</code>
|-
|-
|'''2''' ||<code>''vmin'' < '' ''x''[''i''] < ''vmax''</code>
|'''2''' ||<code>''v''<sub>1</sub> < '' ''x''[''i''] < ''v''<sub>2</sub></code>
|-
|-
|'''3''' ||<code>''x''[i] < ''vmin'' or ''x''[''i''] > ''vmax''</code>
|'''3''' ||<code>''x''[i] < ''v''<sub>1</sub> or ''x''[''i''] > ''v''<sub>2</sub></code>
|-
|-
|'''4''' ||<code>''x''[''i''] <= ''vmin''</code>
|'''4''' ||<code>''x''[''i''] <= ''v''</code>
|-
|-
|'''5''' ||<code>''x''[''i''] >= ''vmax''</code>
|'''5''' ||<code>''x''[''i''] >= ''v''</code>
|-
|-
|'''6''' ||<code>''vmin'' <= '' ''x''[''i''] <= ''vmax''</code>
|'''6''' ||<code>''v''<sub>1</sub> <= '' ''x''[''i''] <= ''v''<sub>2</sub></code>
|-
|-
|'''7''' ||<code>''x''[i] <= ''vmin'' or ''x''[''i''] >= ''vmax''</code>
|'''7''' ||<code>''x''[i] <= ''v''<sub>1</sub> or ''x''[''i''] >= ''v''<sub>2</sub></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''. The function failes, if no row is selected.
:If a boundary ''v'' is a vector, the i-th element of the vectors ''x'' and ''v'' are compared, otherwise the element  ''x''[''i''] is compared with the number ''v''. 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 12:39, 6 April 2011


Extract rows from a vector or matrix.

Usage
vsubc(x , c , v {, y }}) with c = 0, 1, 4 or 5
vsubc(x , 2 , v1, v2 {, y }}) with c = 2, 3, 6 or 7
x
condition vector (and source vector if argument y is not supplied); must be a vector!
v, v1, v2
lower and/or upper 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.
value of c row i is selected if ...
0 x[i] < v
1 x[i] > v
2 v1 < x[i] < v2
3 x[i] < v1 or x[i] > v2
4 x[i] <= v
5 x[i] >= v
6 v1 <= x[i] <= v2
7 x[i] <= v1 or x[i] >= v2
If a boundary v is a vector, the i-th element of the vectors x and v are compared, otherwise the element x[i] is compared with the number v. 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 }
#e := eval vsubc($#a,7,2,4)
// -> vector: $#e = { 1 , 2 , 4 , 5 }

<function list>

Navigation menu

Personal tools