Module 6: Doing Math Part 2
Module 6 Assignment
Another attempt at using R correctly, and as a special treat, I decided to painstakingly enter all values for the last problem for that matrix, because I could not figure out how to properly use diag() to do it.
##Module 6 Doing Math Part 2
#Build and Save two matrices as outlined in the instructions
A <- matrix(c(2,0,1,3),ncol = 2)
B <- matrix(c(5,2,4,-1),ncol = 2)
A
B
#Find A + B
addmatrix <- A + B
addmatrix
#Find A - B
submatrix <- A - B
submatrix
##Problem 2 Use diag() to create a size 4 matrix with values 4,1,2,3 in the diagonal
diagmatrix <- diag(x = c(4,1,2,3))
diagmatrix
##Problem 3 deconstruct a matrix into code sequence
p3 <- matrix(c(3,2,2,2,2,1,3,0,0,0,1,0,3,0,0,1,0,0,3,0,1,0,0,0,3), nrow=5, byrow=TRUE)
Comments
Post a Comment