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=[49310034.59]B=[4.500020003]b=[1193]c=[5.505]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 11 in matrix AA?

  • ...replace the 4.5-4.5 element in matrix AA with an 88?

  • ...to create a vector that contains the main diagonal of matrix BB?

  • ...to create the following matrix by using vector bb? C=[111111999333]C = \begin{bmatrix} 11 & 11 & 11\\ -9 & -9 & -9\\ 3 & 3 & 3 \end{bmatrix}

  • ...to create a 9×19 \times 1 column vector that contains the elements of matrix AA columnwise?

  • ...to create a 9×19 \times 1 column vector that contains the elements of matrix AA rowwise?

  • ... to divide all elements of matrix BB by 2?

  • ... to add matrix AA and BB elementwise?

  • ... to divide matrix AA by BB elementwise?

  • ... to invert matrix BB?

  • ... to create a 9×99 \times 9 identity matrix?

  • ... to create a column vector of 30 linearly spaced numbers from 10 to 110?

  • ... to create a 3×73\times 7 matrix of zeros?

  • ... to extract the second column of AA

  • ... to extract the third row of BB

  • ... to select the lower right 2×22 \times 2 matrix in matrix AA?

  • ... to create a column vector that is the sum of the columns of AA

  • ... to calculate the columnwise mean of BB?

  • ... to get the minimal element of AA?

  • ... to get the maximal element of each column of AA?

  • ... to get the maximal element of each row of AA?

Last updated