[3,] 6 12 18
It looks as below in R Studio while adding both the matrices.
We have already done the addition of two matrices. Now, let us visualize how it has performed the addition operation, using the below images. In the below images, the same color pattern has been used to highlight the element at the same position in both the matrices. For example, the yellow color has been used to highlight the element of the first row and the first column in both matrices.
We can see that in addition to operation, the elements with the same index are added to each other. After addition, the dimension is also the same as it was, i.e., 3 rows and 3 columns.
Subtracting of Matrices
Subtraction of matrices behaves almost the same as it behaves in the case of the addition of two matrices in R. The below code shows how to perform the subtraction operations in matrices in R.