# fill

< Programmer Guide | Command Reference | EVAL

Jump to navigation
Jump to search
## 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:*r*_{i}=*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:*r*_{0}=*x0**r*_{i}=*r*_{i-1}+*dx*_{i-1}; i=1..*n*-1