Assignment #6: Matrix Operations and Construction

To start, we will define matrices A and B, using matrix(). This function creates a dataset with rows and columns. Then compute addition and subtraction:

Then, using diag() we will create a diagonal matrix.

Using  diag() with cbind(), which combines multiple matrices, data frames, or vectors together, we can construct a custom 5×5 matrix very simply.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *