Matrix operation is one of the most commonly used mathematical operations that we perform during data processing and data analysis. All of the matrix operations must be conformable for the operation, mathematically.
The following are the rules that must be followed for matrix operations:
Addition or subtraction rule: There should be at least two vectors, or matrices with the same dimensions
Multiplication rule: There should be at least two vectors or matrices with number of columns of first matrix should be same as the number of rows in second one
Element wise multiplication: For element wise multiplication, both matrices must be of the same dimension
The following is the R code to perform matrix operations:
# Creating random matrix with two 3x3 and one 4x3 dimension # we will use runif() function to generate random number from # standard uniform distribution set.seed(1234) # To make the result reproducible matA <- matrix(rnorm(12),ncol=3) matB <- matrix(rnorm...