Contents Previous Next Subchapters

Changing Matrix Dimensions
Syntax dim variable(rowscolumns)
See Also reshape , rowdim , coldim

Description
Changes the number of rows and columns in a matrix, where rows and columns are non-negative integer scalars.

Tutorial
You can use the dim statement to change the dimensions of an existing matrix. If you enter
     y = seq(12)
     dim y(3, 4)
     print y
the dim statement places the first three elements of the sequence in the first column of y, the next three elements of the sequence in the second column of y, and so on. O-Matrix will respond
     {
     [ 1 , 4 , 7 , 10 ]
     [ 2 , 5 , 8 , 11 ]
     [ 3 , 6 , 9 , 12 ]
     }
If you continue the example above by entering
     dim y(2, 6)
     print y
O-Matrix first converts y to a vector in column major order . O-Matrix then converts the vector into a matrix with the specified dimensions.

O-Matrix will respond
     [ 1 , 3 , 5 , 7 , 9 , 11 ]
     [ 2 , 4 , 6 , 8 , 10 , 12 ]