arranges the elements of list into a rectangular array with dimensions dims.


uses the specified padding if list does not contain enough elements.


  • ArrayReshape always gives a rectangular array of the specified dimensions, ignoring the last elements or adding new elements as necessary.
  • Elements are arranged in the resulting array so that up to length, Flatten[ArrayReshape[list,dims]] is the same as Flatten[list].
  • In ArrayReshape[list,dims,padding], any padding scheme supported by ArrayPad can be specified. The default padding value is 0.
  • ArrayReshape works with SparseArray objects.


open allclose all

Basic Examples  (4)

Create a 2×3 matrix:

Reshape a vector into a depth-3 array:

Use a constant padding value:

Use rule-based padding values:

Scope  (1)

Reshape a matrix into another matrix with different dimensions:

Reshape into a higher rank array:

Generalizations & Extensions  (1)

ArrayReshape works with SparseArray objects:

Applications  (2)

Create an image from a flat list of channel values, effectively inverting the process of flattening image data:

Restructure an array:

Properties & Relations  (2)

A function based on Partition equivalent to ArrayReshape without padding:

Reversing matrix dimensions does not give the same element order as Transpose:

Possible Issues  (1)

Elements from the original list that do not fit in the given dimensions are dropped:

Wolfram Research (2012), ArrayReshape, Wolfram Language function,


Wolfram Research (2012), ArrayReshape, Wolfram Language function,


@misc{reference.wolfram_2021_arrayreshape, author="Wolfram Research", title="{ArrayReshape}", year="2012", howpublished="\url{}", note=[Accessed: 17-May-2021 ]}


@online{reference.wolfram_2021_arrayreshape, organization={Wolfram Research}, title={ArrayReshape}, year={2012}, url={}, note=[Accessed: 17-May-2021 ]}


Wolfram Language. 2012. "ArrayReshape." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2012). ArrayReshape. Wolfram Language & System Documentation Center. Retrieved from