# Math with Matrices¶

• Saving and interacting matrices follow the same rules as the “Saving & Interacting Variables” section, except Matlab assumes interactions follow standard matrix properties such as linear algebra.

• The user can specify different interactions, which we will explore below

• First, let’s create two (2 x 2) matrices called A and B. There are several ways to do this. Using brackets [,] tells Matlab you want to create a matrix. You can use either white space or comma’s to seperate elements in a row. You must use a semicolon to seperate rows.

For example:

• Once you have created a matrix, you can access any element of the matrix by calling with the name of the matrix and the location (row,column) of the element within the matrix. You can also call multiple elements where the colon operator ”:” translates roughly to the word “through”.

For example:

• Now you can interacte these variables just as before, but remember that matrix multiplication involves a dot product and matrix division is the numerator matrix multiplied by the inverse of the denominator matrix.

For example:

• Suppose instead that you would like to multiply or divide each element of the matrix A with the corresponding element of the matrix B. This can easily be done by simply placing a period in front of the multiplication or division operator.

For example:

• It is also straight forward to compute the transpose of a matrix A by simply adding an apostrophe to the expression $$A^{T} = A'$$

In Matlab: