reshape
Reshape an array without changing its data.
Syntax
Section titled “Syntax”B = reshape(A, m, n)B = reshape(A, m, n, p, ...)B = reshape(A, [m n ...])Description
Section titled “Description”Returns an array with the requested dimensions, drawing elements from A in column-major order. The product of the new dimensions must equal numel(A); otherwise an error is raised.
Use one dimension as [] to have it computed automatically: reshape(A, 3, []) makes a 3-row matrix with as many columns as needed.
Examples
Section titled “Examples”reshape(1:12, 3, 4) % 3×4 matrixreshape(1:12, [2 3 2]) % 2×3×2 arrayreshape(magic(4), 2, []) % 2×8 (auto-computed columns)