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

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====fill=====
==Create a vector with equally spaced elements:==
;Usage 1: <code>fill(<var>n</var> {, <var>x0</var> {, <var>dx</var>}})</code>
:;<var>n</var>: vector length, a scalar (>0)
::note: if ''n'' is a vector, ncol(''n'') is used as number of elements
:;<var>x0</var>: start value, must be a scalar (default='''0''')
:;<var>dx</var>: increment, must be a scalar (default='''0''')
;Result 1: The result is a vector r with ''n'' elements. The elements are initialized with:
::<code>''r''<sub>i</sub> = ''x0'' + i*''dx''; i=0..''n''-1''</code>
==Create a vector with variable increment:==
;Usage 2: <code>fill(<var>n</var> , <var>x0</var> , <var>dx</var>)</code>
:;<var>n</var>: vector length, a scalar (>0)
::note: if ''n'' is a vector, ncol(''n'') is used as number of elements
:;<var>x0</var>: start value, must be a scalar
:;<var>dx</var>: increment, must be a vector with at least ''n''-1 elements
;Result 2: The result is a vector r with ''n'' elements. The elements are initialized with:
::<code>''r''<sub>0</sub> = ''x0''</code>
::<code>''r''<sub>i</sub> = ''r''<sub>i-1</sub> + ''dx''<sub>i-1</sub>; i=1..''n''-1''</code>
;See also: [[../init|init]], [[../rand|rand]], [[../vv|vv]]


Create a vector with a linear function.
[[../#Functions|<function list>]]
 
=====Usage:=====
 
<code>fill(<var>n</var>, <var>d</var>, <var>k</var>)</code>
 
=====Parameters:=====
 
;<var>n</var>
 
:The number of elements. There is no default.
 
;<var>d</var>
 
:The start value. The default is <code>0</code>.
 
;<var>k</var>
 
:The increment step value. The default is <code>0</code>.
 
=====Result:=====
 
The result is: x[i = 0..<var>n</var>-1] = <var>d</var> + i*<var>k</var>
 
=====Notes:=====
 
If <var>n</var> is a vector, the length of the vector is used.

Latest revision as of 09:00, 30 September 2015

Create a vector with equally spaced elements:

Usage 1
fill(n {, x0 {, dx}})
n
vector length, a scalar (>0)
note: if n is a vector, ncol(n) is used as number of elements
x0
start value, must be a scalar (default=0)
dx
increment, must be a scalar (default=0)
Result 1
The result is a vector r with n elements. The elements are initialized with:
ri = x0 + i*dx; i=0..n-1

Create a vector with variable increment:

Usage 2
fill(n , x0 , dx)
n
vector length, a scalar (>0)
note: if n is a vector, ncol(n) is used as number of elements
x0
start value, must be a scalar
dx
increment, must be a vector with at least n-1 elements
Result 2
The result is a vector r with n elements. The elements are initialized with:
r0 = x0
ri = ri-1 + dxi-1; i=1..n-1
See also
init, rand, vv

<function list>

Navigation menu

Personal tools