Making a matrix with a list: list2mat

### 6.40.32 Making a matrix with a list: list2mat

The listmat command turns a list into a matrix by chopping up the list into separate rows.

- list2mat takes two arguments:
  - L, a list.
  - p, a postive integer.
- list2mat(L,p) returns the matrix whose first row consists of the first p elements of L, whose next row consists of the next p elements of L, etc. If there are not enough elements to fill up a row, 0s are added.

Examples.

- Input:
  list2mat([5,8,1,9,5,6],2)
  Output:

  ⎛ ⎜ ⎜ ⎝ |
  5 | 8
  1 | 9
  5 | 6
  | ⎞ ⎟ ⎟ ⎠

- Input:
  list2mat([5,8,1,9],3)
  Output:

  ⎛ ⎜ ⎝ |
  5 | 8 | 1
  9 | 0 | 0
  | ⎞ ⎟ ⎠