Recall & Review
beginner
What does the
zeros(n) function do in MATLAB?It creates an n-by-n matrix filled with zeros. For example,
zeros(3) makes a 3x3 matrix where every element is 0.Click to reveal answer
beginner
How do you create a matrix of all ones with 2 rows and 4 columns in MATLAB?
Use
ones(2,4). This creates a 2x4 matrix where every element is 1.Click to reveal answer
beginner
What is the purpose of the
eye(n) function in MATLAB?It creates an identity matrix of size n-by-n. This matrix has 1s on the diagonal and 0s elsewhere.
Click to reveal answer
beginner
What does the
rand(m,n) function generate in MATLAB?It creates an m-by-n matrix filled with random numbers between 0 and 1. Each number is different every time you run it.
Click to reveal answer
intermediate
How can you create a 4x4 identity matrix and then multiply it by 5 in MATLAB?
First create the identity matrix with
eye(4), then multiply by 5: 5 * eye(4). This results in a 4x4 matrix with 5s on the diagonal and 0s elsewhere.Click to reveal answer
What will
zeros(2,3) create?✗ Incorrect
zeros(2,3) creates a matrix with 2 rows and 3 columns filled with zeros.Which function creates an identity matrix in MATLAB?
✗ Incorrect
eye(n) creates an n-by-n identity matrix with 1s on the diagonal.What range of values does
rand(3,3) generate?✗ Incorrect
rand generates random decimal numbers between 0 and 1.How do you create a 5x5 matrix of all ones?
✗ Incorrect
ones(5,5) creates a 5x5 matrix filled with ones.What does
eye(3)*2 produce?✗ Incorrect
Multiplying the identity matrix by 2 doubles the diagonal elements, leaving zeros elsewhere.
Explain how to create special matrices in MATLAB using zeros, ones, eye, and rand functions.
Think about what each function fills the matrix with.
You got /4 concepts.
Describe a real-life situation where you might use an identity matrix created by eye(n) in MATLAB.
Think about how multiplying by 1 keeps a number the same.
You got /4 concepts.