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

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 9: Line 9:


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


[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Revision as of 15:47, 6 April 2011

Extract rows from a vector or matrix.

Usage
vsubn(x {, o {, n}})
x
source vector or matrix
o
offset, 0 <= o < nrow(x) (default=0)
n
length, n > 0 and o+n <= nrow(x) (default=nrow(x)-o)
Result
A numerical object with ncol(x) columns and n rows, consisting of the rows o to o+n-1 of the argument x.
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