Group: | Matrix Manipulation |
Topic: | Sorting and Counting |
See also: | {} reduce vec |
Function: | reshape | |
Description: | reshape transforms an array into a new one with given dimensions. |
Usage: | y = reshape(x,d) | |
Input: | ||
x | multidimensional array (or string) | |
d | vector containing the new dimensions | |
Output: | ||
y | array, witch has the dimension d |
To save memory it is possible to reshape an object itself by giving the name of the object, e.g., reshape ("x", #(2,5,2)). Then reshape has no result.
x=1:20 reshape(x,#(2,5,2))
Contents of reshape [,,1,1,1,1,1,1] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10 [,,2,1,1,1,1,1] [1,] 11 13 15 17 19 [2,] 12 14 16 18 20