Assignment 6
# Part 1
> A <- matrix(c(2,0,1,3), ncol=2)
> B <- matrix(c(5,2,4,-1), ncol=2)
> A + B
[,1] [,2]
[1,] 7 5
[2,] 2 2
> A - B
[,1] [,2]
[1,] -3 -3
[2,] -2 4
# Part 2
> diag(c(4,1,2,3))
[,1] [,2] [,3] [,4]
[1,] 4 0 0 0
[2,] 0 1 0 0
[3,] 0 0 2 0
[4,] 0 0 0 3
# Part 3
> 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 = FALSE)
[,1] [,2] [,3] [,4] [,5]
[1,] 3 1 1 1 1
[2,] 2 3 0 0 0
[3,] 2 0 3 0 0
[4,] 2 0 0 3 0
[5,] 2 0 0 0 3
Comments
Post a Comment