# Basic Matrix manipulation commands

• `sum` – Creates a row matrix that whose elements sum up the elements in each of the columns of the previous matrix. • `prod` – Carries out a product of the elements in each column of the matrix. • `diag` –  The output of this command is dependent on the type of matrix it acts upon. For a square matrix, it creates a column vector of the leading-diagonal elements of the square matrix. For a row matrix, it creates a diagonal matrix whose elements are those of the row vector.  • `sort` – Rearranges the elements in a matrix so that in each column they are in ascending order with the smallest at the top. • `flip` – Literally flips the order of the elements in a matrix. `fliplr` flips the matrix left to right and `flipud` causes up to down rearrangement. It is more useful to specify direction of reordering as the `flip` command usually causes the up to down rearrangement as well.
• `round` – This is used to round the elements of a matrix to the nearest whole number.
• `reshape` – This is used to alter the shape of the matrix. The new matrix must have the same number of elements. The new dimensions also have to be specified along with the command. CHECKPOINT:  Do this and you’re a legend.

Create an M-file that would carry out the following:

Starting with a magic-3 matrix, create a row matrix which comprises the rank of the matrix and its eigenvalues to the nearest whole number (starting with the smallest first) in that order. Duplicate the row four times, so you generate a square matrix. Reverse the order of the elements in the second row. Switch the first and the last elements of the third row. Find the transpose of the resulting matrix. Name the final matrix `ILU` for “I love UCL” (or `IHU` if you like).

(Hint: you need to make a number of small matrices and then Concatenate!)