gives an array with m zeros of padding on every side.


uses the specified padding.


pads with m elements at the beginning and n elements at the end.


pads with mi, ni elements at level i in array.

Details and Options

  • The following forms of padding can be specified:
  • ca constant c
    {c1,c2,}cyclic repetition of constants c1,
    "Extrapolated"polynomial extrapolation of elements
    "Fixed"repetitions of the elements on each boundary
    "Periodic"cyclic repetitions of the complete array
    "Reflected"reflections of the array in the boundary
    "ReflectedDifferences"reflections of the differences between elements
    "Reversed"reversals of the complete array
    "ReversedDifferences"reversals of the differences between elements
    "ReversedNegation"negated reversals of the array
  • The padding value "Fixed" indicates that the elements added at each corner should be copies of the elements at the corners of the original array.
  • "Reversed" indicates that the outermost elements in the array should be repeated as the innermost elements in the padding. "Reflected" specifies that these elements should not be repeated.
  • With the padding value "Extrapolated", the degree of polynomial used is specified by the option InterpolationOrder.
  • ArrayPad pads full arrays of any depth.
  • ArrayPad works with SparseArray objects.
  • ArrayPad[array,-m] removes m elements from each side of array.


open allclose all

Basic Examples  (6)

Pad the edges of a list with 0s:

Pad the edges of a matrix:

Specify different padding on each side:

Pad with any expression:

Pad according to a named rule:

Pad by 5 elements on each row and 1 element on each column:

Scope  (12)

Pad only on the right:

Remove elements from each edge of an array:

Pad with extra rows:

Pad with extra columns:

Specify different padding for each edge:

Pad only the first level of an array:

Pad by repeating periodically:

Pad with the reversal of the list:

Pad with the negative of the reversal:

Pad by reflecting about the edge:

Pad antisymmetrically about the value at the edge:

Pad antisymmetrically about the edge of the array with reversed differences:

The differences are reflected about the edge of the original array:

Pad using linear extrapolation:

Pad using extrapolation of different orders:

Pad using the maximal extrapolation order:

Generalizations & Extensions  (1)

ArrayPad works with SparseArray objects:

Options  (3)

InterpolationOrder  (3)

Specify the order of interpolation for "Extrapolated" padding:

By default, linear interpolation is used:

Use the maximum possible order, in this case order 3:

Applications  (1)

Lay out tiles by reflecting about their edges:

Properties & Relations  (2)

PadLeft[list,n] and PadRight[list,n] pad to make a list of length n:

ArrayPad[list,n] pads with n additional elements on each side:

ArrayPad[list,{-n,0}] is effectively Drop[list,n] for a one-dimensional list:

ArrayPad[list,{0,-n}] is effectively Drop[list,-n]:

Possible Issues  (2)

A single number or pair of numbers is interpreted to apply in each dimension:

Explicitly specify the padding amount in each dimension:

Normally even empty array dimensions are padded:

With padding types that depend on array values, only nonempty array dimensions are padded:

Neat Examples  (1)

Visualize the different named padding rules:

Wolfram Research (2008), ArrayPad, Wolfram Language function,


Wolfram Research (2008), ArrayPad, Wolfram Language function,


@misc{reference.wolfram_2020_arraypad, author="Wolfram Research", title="{ArrayPad}", year="2008", howpublished="\url{}", note=[Accessed: 26-January-2021 ]}


@online{reference.wolfram_2020_arraypad, organization={Wolfram Research}, title={ArrayPad}, year={2008}, url={}, note=[Accessed: 26-January-2021 ]}


Wolfram Language. 2008. "ArrayPad." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2008). ArrayPad. Wolfram Language & System Documentation Center. Retrieved from