Matrix and Array 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 Array Operations flashcards as text
What does `eye(4)` create in MATLAB?
Answer: A 4×4 identity matrix
`eye(n)` creates an n×n identity matrix with ones on the main diagonal and zeros elsewhere.
What is the result of `reshape([1 2 3 4 5 6], 2, 3)` in MATLAB?
Answer: [1 3 5; 2 4 6]
MATLAB fills matrices column-by-column, so reshape fills column 1 with [1;2], column 2 with [3;4], column 3 with [5;6].
What does the `diag(A)` function return when A is a square matrix?
Answer: A vector of A's main diagonal elements
When passed a matrix, `diag` extracts the main diagonal as a column vector.
Which MATLAB function computes the determinant of a square matrix?
Answer: det(A)
`det(A)` computes the determinant of square matrix A.
What does `A'` (apostrophe) do to a complex matrix A in MATLAB?
Answer: Returns the complex conjugate transpose (Hermitian)
The apostrophe `'` operator computes the complex conjugate transpose; for real matrices it is the same as a plain transpose.
What is returned by `sum([1 2 3; 4 5 6])` in MATLAB?
Answer: [5 7 9]
By default `sum` operates along the first dimension (columns), returning a row vector of column sums [5 7 9].
Which MATLAB syntax creates a 3×3 matrix of random integers between 1 and 10?
Answer: randi(10, 3, 3)
`randi(imax, m, n)` generates an m×n matrix of uniformly distributed random integers between 1 and imax.