# MATLAB TUTORIAL, part 2.1: Basic Matrix Operations

Basic Matrix Operations

matlab can carry out a wide array (no pun intended) of operations on the matrices that you define. Try addition and multiplication for starters. Observe what happens:

A = [1 2; 3 4]
B = [5 6; 7 8]
AplusB = A + B
AtimesB = A * B
AtimesB is A times B, which is the result of standard matrix multiplication from linear algebra. However, often one is interested in the element by element multiplication of two matrices. The way to do this in matlab is using the .* operator, where the dot indicated element by element calculation. Try it, and compare the results:
			AtimeseeB = A .* B
Other operations that we have discussed in class include calculating the transpose, the complex conjugate and the adjoint of a matrix. The transpose of a real-valued matrix
			C=[1 2; 3 4]
is simply
			C'
while for a matrix
		D=[1+i 2; 3 4]
that also contains some complex entries
			D'
calculates the complex conjugate. To calculate the transpose of such a matrix, one has to use the familiar .:
			D.'

Theorem: If the sizes of the matrices are such that the stated operations can be performed, then:

• $$\left({\bf A}^T \right)^T = {\bf A}$$ for any matrix A;
• $$\left( {\bf A} + {\bf B} \right)^T = {\bf A}^T + {\bf B}^T .$$
• $$\left( {\bf A} - {\bf B} \right)^T = {\bf A}^T - {\bf B}^T .$$
• $$\left( k\,{\bf A} \right)^T = k\, {\bf A}^T .$$
• $$\left( {\bf A} \, {\bf B}\right)^T = {\bf B}^T \, {\bf A}^T .$$


Complete

Applications