☕
An Introduction to MATLAB
  • An Introduction to MATLAB
  • Where do I start?
  • 1. Crashcourse
    • Intro to Crashcourse
    • Graphical User Interface
    • Essential commands
      • Matrix Input and Access
      • Matrix Algebra
      • Logical Operations
    • Best practices
    • Self-Assessment
    • Applied exercises
  • 2. MATLAB Programming
    • Intro to MATLAB Programming
    • Programming Fundamentals
    • Conditions
    • Loops
    • Custom Functions
    • Debugging
    • Applied Exercises
  • 3. Data, Graphics & Reporting
    • Intro to Data, Graphics & Reporting
    • Working with Datasets
    • Creating Graphs
    • Applied Exercises
  • 4. RNGs & Simulations
    • Intro to RNGs & Simulations
    • Random Number Generation
    • Monte-Carlo Simulations
    • Applied Exercises
  • 5. Numerical Methods
    • Intro to Numerical Methods
    • Numerical Optimization
    • Numerical Solvers
    • Applied Exercises
Powered by GitBook
On this page
  • Creating vectors and matrices
  • Basic commands

Was this helpful?

  1. 1. Crashcourse

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=[4931003−4.59]B=[4.500020003]b=[11−93]c=[5.50−5]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}A=​413​90−4.5​309​​B=​4.500​020​003​​b=​11−93​​c=[5.5​0​−5​]

Basic commands

Which command would you use to...

  • ...access the element containing 111 in matrix AAA?

  • ...replace the −4.5-4.5−4.5 element in matrix AAA with an 888?

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

  • ...to create the following matrix by using vector bbb? C=[111111−9−9−9333]C = \begin{bmatrix} 11 & 11 & 11\\ -9 & -9 & -9\\ 3 & 3 & 3 \end{bmatrix}C=​11−93​11−93​11−93​​

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

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

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

  • ... to add matrix AAA and BBB elementwise?

  • ... to divide matrix AAA by BBB elementwise?

  • ... to invert matrix BBB?

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

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

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

  • ... to extract the second column of AAA

  • ... to extract the third row of BBB

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

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

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

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

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

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

PreviousBest practicesNextApplied exercises

Last updated 5 years ago

Was this helpful?