Creating a matrix from a list

### 5.3.32 Creating a matrix from a list

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, zeros are added.

#### Examples

list2mat([5,8,1,9,5,6],2)

⎡ ⎢ ⎢ ⎣ |
5 | 8
1 | 9
5 | 6
| ⎤ ⎥ ⎥ ⎦

list2mat([5,8,1,9],3)

⎡ ⎢ ⎣ |
5 | 8 | 1
9 | 0 | 0
| ⎤ ⎥ ⎦