Code Studio: Matrix Access
Combine Challenges 1 and 3 from Practice: Arrays and Matrices.
- Create a 4×4 matrix
mfrom the numbers 1 to 16, filled by row (look at thebyrowargument ofmatrix()). - Name the rows
row1torow4and the columnscol1tocol4(look atdimnames). - Print the whole matrix.
- Print the element in the 2nd row, 3rd column.
- Print only the 3rd row, then only the 4th column.
Print each part with print(), in that order. Press Run often: the matrix printout tells you immediately whether you filled it by row or by column.
Combine Challenges 1 and 3 from Practice: Arrays and Matrices.
- Create a 4×4 matrix
mfrom the numbers 1 to 16, filled by row (look at thebyrowargument ofmatrix()). - Name the rows
row1torow4and the columnscol1tocol4(look atdimnames). - Print the whole matrix.
- Print the element in the 2nd row, 3rd column.
- Print only the 3rd row, then only the 4th column.
Print each part with print(), in that order. Press Run often: the matrix printout tells you immediately whether you filled it by row or by column.