Version:

Adds elements to an array of any dimension. padarray(x, n) adds n zeros to both ends of x.

## Syntax

y = padarray(x, n)
y = padarray(x, n, element)
y = padarray(x, n, option)
y = padarray(x, n, element, direction)
y = padarray(x, n, option, direction)

## x

Array to add elements to. x is an array of any dimension.

## n

Number of elements to add to each dimension of x. n is a vector. The length of n must be equal to the number of dimensions of x.

## element

Element to add to x repeatedly. element is a scalar.

Default: 0

## option

Specifies how to add elements to x. option is a string that accepts the following values:

Name Description
'circular'

Adds elements by circularly repeating the existing elements.

'replicate'

Adds elements by repeating the element on the border.

'symmetric'

## direction

Direction to add elements to x. direction is a string that accepts the following values:

Name Description
'both'

Adds elements to both ends of x.

'pre'

Adds elements before the start of x.

'post'

Adds elements after the end of x.

Default: 'both'

## y

X = rand(10, 1);
Y = padarray(X, 6, 0, 'post')