gives an array with m 0s 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:
•  c a 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.

Examples

open allclose all

Basic Examples(5)

Pad the edges of a list with 0s:

 In[1]:=
 Out[1]=

Pad the edges of a matrix:

 In[1]:=
 Out[1]//MatrixForm=

Specify different padding on each side:

 In[1]:=
 Out[1]=

Pad with any expression:

 In[1]:=
 Out[1]=

Pad according to a named rule:

 In[1]:=
 Out[1]=