Matrix and Vector Operations Flashcards
7 cards from real MATLAB practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Matrix and Vector Operations flashcards as text
What does the MATLAB expression `A \ b` compute when A is a square matrix?
Answer: The solution x to the linear system A*x = b
The backslash operator solves the linear system A*x = b using efficient factorization, equivalent to inv(A)*b but numerically more stable.
Which MATLAB function returns both eigenvalues and eigenvectors of a matrix A?
Answer: [V, D] = eig(A)
With two output arguments, eig returns V (eigenvectors as columns) and D (diagonal matrix of eigenvalues).
What is the result of `dot([1 2 3], [4 5 6])` in MATLAB?
Answer: 32
The dot product is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32.
How do you extract the diagonal elements of matrix A as a column vector in MATLAB?
Answer: diag(A)
diag(A) extracts the main diagonal of matrix A and returns it as a column vector.
What does `rank(A)` return for a 4x4 identity matrix?
Answer: 4
The identity matrix has 4 linearly independent rows and columns, so its rank is 4 (full rank).
Which operation computes the Hadamard (element-wise) product of two matrices A and B in MATLAB?
Answer: A .* B
The .* operator performs element-wise multiplication, requiring A and B to have identical dimensions.
What does `triu(A)` return for a matrix A?
Answer: The upper triangular part of A
triu extracts the upper triangular portion of matrix A, setting all elements below the main diagonal to zero.