← All MATLAB Flashcard Decks

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
  1. What does `A(end, :)` return for a matrix A?

    Answer: The last row of A

    The colon : selects all columns, and end refers to the last row index, returning the entire last row.

  2. How do you horizontally concatenate two matrices A and B with the same number of rows in MATLAB?

    Answer: [A, B]

    [A, B] or [A B] concatenates A and B side by side, requiring equal row counts; equivalently horzcat(A,B).

  3. What does `trace(A)` return for a matrix A?

    Answer: The sum of diagonal elements

    trace returns the sum of the main diagonal elements of a square matrix.

  4. What is the result of `[1 2 3] > 2` in MATLAB?

    Answer: Both B and C are correct

    MATLAB returns a logical array [0 0 1] (equivalently [false false true]) where the condition is satisfied.

  5. Which MATLAB function sorts a matrix A along its columns in ascending order?

    Answer: Both A and B

    sort(A) and sort(A, 1) both sort each column independently in ascending order (dimension 1 = along rows).

  6. What does `max(max(A))` compute for a matrix A?

    Answer: The overall maximum element

    The inner max finds the maximum of each column (a row vector), then the outer max finds the maximum of those maxima.

  7. In MATLAB, what is `linspace(0, 1, 5)`?

    Answer: [0 0.25 0.5 0.75 1]

    linspace(0, 1, 5) generates 5 equally spaced points from 0 to 1 inclusive: [0, 0.25, 0.5, 0.75, 1].