> For the complete documentation index, see [llms.txt](https://coding-courses.gitbook.io/matlab/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coding-courses.gitbook.io/matlab/crashcourse/self-assessment.md).

# Self-Assessment

Use the exercises and questions below to check that you have the required basic MATLAB knowledge to continue with the rest of the course.

## Creating vectors and matrices

Input the following vectors and matrices into MATLAB. Are there multiple commands that you can use to create these objects?

$$
A = \begin{bmatrix} 4 & 9 & 3\ 1 & 0 & 0\ 3 & -4.5 & 9 \end{bmatrix}\hspace{20pt} B = \begin{bmatrix} 4.5 & 0 & 0\ 0 & 2 & 0\ 0 & 0 & 3 \end{bmatrix}\hspace{20pt} b = \begin{bmatrix} 11\ -9\ 3 \end{bmatrix}\hspace{20pt} c = \begin{bmatrix} 5.5 & 0 & -5 \end{bmatrix}
$$

## Basic commands

Which command would you use to...

* ...access the element containing $$1$$ in matrix $$A$$?
* ...replace the $$-4.5$$ element in matrix $$A$$ with an $$8$$?
* ...to create a vector that contains the main diagonal of matrix $$B$$?
* ...to create the following matrix by using vector $$b$$? $$C = \begin{bmatrix} 11 & 11 & 11\ -9 & -9 & -9\ 3 & 3 & 3 \end{bmatrix}$$
* ...to create a $$9 \times 1$$ column vector that contains the elements of matrix $$A$$ columnwise?
* ...to create a $$9 \times 1$$ column vector that contains the elements of matrix $$A$$ rowwise?
* ... to divide all elements of matrix $$B$$ by 2?
* ... to add matrix $$A$$ and $$B$$ elementwise?
* ... to divide matrix $$A$$ by $$B$$ elementwise?
* ... to invert matrix $$B$$?
* ... to create a $$9 \times 9$$ identity matrix?
* ... to create a column vector of 30 linearly spaced numbers from 10 to 110?
* ... to create a $$3\times 7$$ matrix of zeros?
* ... to extract the second column of $$A$$
* ... to extract the third row of $$B$$
* ... to select the lower right $$2 \times 2$$ matrix in matrix $$A$$?
* ... to create a column vector that is the sum of the columns of $$A$$
* ... to calculate the columnwise mean of $$B$$?
* ... to get the minimal element of $$A$$?
* ... to get the maximal element of each column of $$A$$?
* ... to get the maximal element of each row of $$A$$?
