Contents Previous Next Subchapters Current Chapters-> assignment clear const elements pi building exit include auto_include comment printexp print stop coldim rowdim size dim reshape MatrixAsVector Parent Chapters-> Omatrix6 basic dim Search Tools-> contents reference index search

Changing Matrix Dimensions
 Syntax `dim `variable`(`rows`, `columns`)` 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 ] ```