Matrix Reshape

Rearrange a matrix's values into a new shape reading them in row-major order.

Description

Reshape matrix values into new row and column dimensions while preserving row-major order.

Matrix reshape changes the dimensions of grid data without changing its value sequence. It is useful when preparing arrays for an algorithm, converting a row vector into a grid, or checking row-major layout conventions.

When to use Matrix Reshape Tool

  • Convert a flat or narrow matrix into a requested grid
  • Prepare values for an operation with a required shape
  • Verify row-major serialization and reconstruction

How the calculation works

The source matrix is flattened row by row, then sliced into the requested number of rows and columns. Reshaping is allowed only when rows × columns equals the number of source values.

source element count = rows × columns

Interpreting the result

The first source value remains first, followed by the rest in row-major sequence. Only grouping changes. Reshaping does not transpose axes, reorder values, interpolate cells, or change numeric content.

Important limitations

  • Requested dimensions must be positive integers.
  • The total element count must remain exactly the same.
  • The source must be non-empty; ragged input should be normalized before reshaping.
Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies