Consider the following MATLAB code that multiplies two matrices. What is the output?
A = [1 2; 3 4]; B = [5 6; 7 8]; C = A * B; disp(C);
Remember how matrix multiplication works: multiply rows of the first matrix by columns of the second.
Matrix multiplication sums the products of rows of A with columns of B. For example, first element: 1*5 + 2*7 = 19.
Which reason best explains why MATLAB is designed around linear algebra operations?
Think about the main users of MATLAB and their needs.
MATLAB was built to solve math problems in engineering and science, where linear algebra is key.
What error will this MATLAB code produce?
A = [1 2 3; 4 5 6]; B = [7 8; 9 10]; C = A * B;
Check the sizes of A and B before multiplying.
Matrix multiplication requires the number of columns in A to equal the number of rows in B. Here, A is 2x3 and B is 2x2, so multiplication is invalid.
Choose the MATLAB code that correctly creates a 3x3 identity matrix.
MATLAB has a built-in function named 'eye' for identity matrices.
The function eye(n) creates an n-by-n identity matrix. Other options are invalid or create different matrices.
Calculate the determinant of the matrix M = [2 3 1; 4 1 5; 7 2 6] in MATLAB.
M = [2 3 1; 4 1 5; 7 2 6]; detM = det(M); disp(detM);
Use the det function and carefully calculate the determinant.
The determinant of M is -24, calculated by expansion or MATLAB's det function.