Creates a new matrix from an existing matrix with dimensions you specified in the shape-descriptor array.
RESHAPE produces valid results for any matrix with any given shape dimensions, getting values from M in a cyclic fashion.
Format
RESHAPE (M,S)
Arguments
M | A matrix. |
S | A shape-descriptor array. Can contain up to two dimensions. |
Examples
The following example illustrates the use of the RESHAPE function:
Function | RESHAPE({1, 0, 0, 0}, {3, 3}) |
Result | {[1, 0, 0], [0, 1, 0], [0, 0, 1]} |
Because scalars are coerced into 1x1 matrices, you can also have the following:
Function | RESHAPE(1, {2, 2}) |
Result | {[1, 1], [1, 1]} |