← All MATLAB Flashcard Decks

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
  1. What does logical indexing `A(A > 5)` return for matrix A = [1 6; 3 8]?

    Answer: A column vector [6; 8]

    Logical indexing selects elements satisfying the condition and returns them as a column vector in column-major order.

  2. What is the MATLAB operator for element-wise division?

    Answer: ./

    `./` divides corresponding elements of two arrays, whereas `/` performs matrix right division.

  3. What does `fliplr([1 2 3; 4 5 6])` return?

    Answer: [3 2 1; 6 5 4]

    `fliplr` flips the matrix left-to-right (reverses columns), producing [3 2 1; 6 5 4].

  4. What is the purpose of the backslash operator `A \ b` in MATLAB?

    Answer: Solves the linear system Ax = b for x

    `A \ b` uses Gaussian elimination to solve Ax = b, which is numerically preferred over `inv(A)*b`.

  5. How do you concatenate two matrices A (3×2) and B (3×3) horizontally in MATLAB?

    Answer: [A, B]

    `[A, B]` or equivalently `horzcat(A, B)` concatenates matrices side by side, requiring the same number of rows.

  6. Which function returns the eigenvalues and eigenvectors of a square matrix A?

    Answer: eig(A)

    `[V, D] = eig(A)` returns eigenvectors in columns of V and eigenvalues on the diagonal of D.

  7. What does `A(end, :)` select from matrix A?

    Answer: The last row of A

    `end` refers to the last index in that dimension, so `A(end, :)` selects all columns of the last row.