Module #6
For this assignment, I created four matrices based on the given A and B data. Here are my results:
> A <- matrix(c(2, 0, 1, 3), ncol = 2) > B <- matrix(c(5, 2, 4, -1), ncol = 2) > Matrix_one <- A + B > Matrix_one [,1] [,2] [1,] 7 5 [2,] 2 2 > Matrix_two <- A - B > Matrix_two [,1] [,2] [1,] -3 -3 [2,] -2 4 > diag_matrix <- diag(c(4, 1, 2, 3)) > diag_matrix [,1] [,2] [,3] [,4] [1,] 4 0 0 0 [2,] 0 1 0 0 [3,] 0 0 2 0 [4,] 0 0 0 3 > final_matrix <- diag(3, 5) > final_matrix [,1] [,2] [,3] [,4] [,5] [1,] 3 0 0 0 0 [2,] 0 3 0 0 0 [3,] 0 0 3 0 0 [4,] 0 0 0 3 0 [5,] 0 0 0 0 3 | |
|
Comments
Post a Comment