Complete the code to create a 3x3 matrix of zeros.
A = [1](3, 3);
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);
The eye function creates an identity matrix. eye(4) creates a 4x4 identity matrix with ones on the diagonal and zeros elsewhere.
Fix the error in the code to create a 2x5 matrix of random numbers between 0 and 1.
R = [1](2, 5);
The rand function creates a matrix of random numbers between 0 and 1. rand(2, 5) creates a 2x5 matrix with random values.
Fill both blanks to create a 5x5 matrix of ones and then replace the diagonal with zeros.
M = [1](5); M([2]) = 0;
First, ones(5) creates a 5x5 matrix filled with ones. Then, 1:6:numel(M) selects the diagonal elements of the matrix M. Setting these to zero replaces the diagonal with zeros.
Fill all three blanks to create a 3x4 matrix of random numbers, then create a 4x4 identity matrix, and finally a 2x2 matrix of zeros.
A = [1](3, 4); B = [2](4); C = [3](2, 2);
rand(3, 4) creates a 3x4 matrix with random numbers. eye(4) creates a 4x4 identity matrix. zeros(2, 2) creates a 2x2 matrix filled with zeros.