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

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 41: Line 41:


The result is a scalar or a vector with the selected elements from <var>x1</var> (or <var>x2</var> - see <var>x2</var> for details).
The result is a scalar or a vector with the selected elements from <var>x1</var> (or <var>x2</var> - see <var>x2</var> for details).
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
Extract rows from a vector or matrix.
;Usage: '''<code>vsubc(<var>x</var> , 0 , <var>vmin</var> {, <var>y</var> }})</code>'''
::'''<code>vsubc(<var>x</var> , 1 , <var>vmax</var> {, <var>y</var> }})</code>'''
::'''<code>vsubc(<var>x</var> , 2 , <var>vmin</var>, <var>vmax</var> {, <var>y</var> }})</code>'''
::'''<code>vsubc(<var>x</var> , 3 , <var>vmin</var>, <var>vmax</var> {, <var>y</var> }})</code>'''
:;<var>x</var>: condition vector (and source vector if argument ''y'' is not supplied); must be a vector!
:;<var>vmin</var>: lower boundary; must be a scalar or a vector with the same length as ''x''
:;<var>vmax</var>: upper boundary; must be a scalar or a vector with the same length as ''x''
:;<var>y</var>: optional source data; must be a vector or matrix with the same number of rows as ''x''
;Result: A numerical object with <code>nrow(''x'')</code> columns and ''n'' rows, consisting of the rows ''o'' to ''o''+''n''-1 of the argument ''x''.
;Description: The 2nd argument ''c'' (a number in the range 0..3) defines the condition used for the selection of the source rows.
;* 2nd argument is '''0'''
;See also: [[Programmer_Guide/Command_Reference/EVAL/vsubc|vsubc]], [[Programmer_Guide/Command_Reference/EVAL/select|select]],
[[Programmer_Guide/Command_Reference/EVAL/vvset|vv]]
Example:
<pre>
#a := eval vv(1,2,3,4,5)
#b := eval vmcol($#a, vv(5,4,3,2,1))
#c := vsubn($#a,3)
// -> vector: $#c = { 4 , 5 }
#d := eval vsubn($#b, 1 , 3)
// -> matrix: $#d[*,0] = { 2 , 3 , 4 },  $#d[*,1] = { 4 , 3 , 2 }
#e := eval vsubn($#a, 2, 1)
// -> scalar: $#e = 2, this is equivalent to $#a[2]
#f := eval vsubn($#b, 2, 1)
// -> vector (!!): $#f = { 3 , 3 }, this is equivalent to $#b[2,*]
</pre>
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Revision as of 10:45, 6 April 2011

vsubc

Conditional extraction of elements from the vector x.

Usage:

vsubc(x1,c,s1,x2)

vsubc(x1,c,s1,s2,x2)

Parameters:
x1
The input vector.
c
The condition. The following values are supported:
0 - select all x[i] where x[i] < s1
1 - select all x[i] where x[i] > s1
2 - select all x[i] where s1 < x[i] < s2
s1
A real number. See c for details.
s2
A real number (only used if c==2). See c for details.
x2
x2 is optional. If specified, the elements in x2 are extracted based on the selected values in x1. x2 must be a vector with exactly the same number of rows as x1.
Result:

The result is a scalar or a vector with the selected elements from x1 (or x2 - see x2 for details).


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 with nrow(x) columns and n rows, consisting of the rows o to o+n-1 of the argument x.
Description
The 2nd argument c (a number in the range 0..3) defines the condition used for the selection of the source rows.
  • 2nd argument is 0
See also
vsubc, select,

vv

Example:

#a := eval vv(1,2,3,4,5)
#b := eval vmcol($#a, vv(5,4,3,2,1))
#c := vsubn($#a,3)
// -> vector: $#c = { 4 , 5 }
#d := eval vsubn($#b, 1 , 3)
// -> matrix: $#d[*,0] = { 2 , 3 , 4 },  $#d[*,1] = { 4 , 3 , 2 }
#e := eval vsubn($#a, 2, 1)
// -> scalar: $#e = 2, this is equivalent to $#a[2]
#f := eval vsubn($#b, 2, 1)
// -> vector (!!): $#f = { 3 , 3 }, this is equivalent to $#b[2,*]

<function list>

Navigation menu

Personal tools