Complete the code to create a 3x3 matrix of zeros.
A = [1](3,3);
ones instead of zeros creates a matrix of ones.eye creates an identity matrix, not zeros.The zeros function creates a matrix filled with zeros. Here, zeros(3,3) creates a 3x3 matrix of zeros.
Complete the code to create a 4x4 identity matrix.
I = [1](4);
zeros creates a matrix of zeros, not identity.ones creates a matrix of ones, not identity.The eye function creates an identity matrix. eye(4) creates a 4x4 identity matrix.
Fix the error in the code to create a 2x5 matrix filled with ones.
M = [1](2, 5);
zeros creates a matrix of zeros.eye creates an identity matrix, which is square.The ones function creates a matrix filled with ones. ones(2,5) creates a 2x5 matrix of ones.
Fill both blanks to create a 3x3 matrix with random values between 0 and 1.
R = [1]([2], 3);
randn generates random numbers with a normal distribution.The rand function creates a matrix with random values between 0 and 1. rand(3,3) creates a 3x3 matrix.
Fill both blanks to create a 2x4 matrix of twos using element-wise multiplication.
M = [1](2, 4) [2] 2;
* instead of element-wise .* causes errors.ones(2,4) creates a matrix of ones. Using element-wise multiplication .* with 2 multiplies each element by 2. The last blank is empty because no extra operator is needed.