Module 5
This a 10 x 10 in R. Matrix A contains the numbers 1 - 100, and the Matrix B contains the numbers 1 - 1,000. The matrix() function arranges the numbers into rows and columns so they can be used to matrix calculations. By specifying nrow = 10, it tells R to place the numbers into 10 rows. Since there are 100 values total, R fill 10 columns automatically. That how you get the 10 x 10 square matrix.
With the 1:1000, it creates a sequence from 1 to 1000. The matrix () functions arrange the numbers into 10 rows, since there is 1000 numbers total, R creates 100 columns (1000 / 10 = 100). So, B becomes a 10 100 matrix, which is rectangular rather than square. This matters since there is only square matrices and can have determinants and inverses.
The rm() function removes all existing objects from memory and ensure that no old variables interfere with your results. 1 :100 created numbers from 1 to 100. These numbers were arranged into 10 rows, producing a 10 x 10 matrix for A. 1: 1000 creates numbers from 1 to 1000. Arranged into 10 rows, producing a 10 x 100 matrix for B.
.png)
.png)
.png)
Comments
Post a Comment