Bird
0
0

What is the output of the following MATLAB code?

medium📝 Predict Output Q4 of 15
MATLAB - Linear Algebra
What is the output of the following MATLAB code?
A = [1 2 3; 4 5 6];
B = A';
disp(B);
A[1 4; 2 5; 3 6]
B[1 2 3; 4 5 6]
C[1 4 2; 5 3 6]
D[1 4 5; 2 3 6]
Step-by-Step Solution
Solution:
  1. Step 1: Understand original matrix A

    A is a 2x3 matrix: first row [1 2 3], second row [4 5 6].
  2. Step 2: Transpose matrix A

    Transpose swaps rows and columns, so B becomes 3x2 with columns of A as rows: [1 4; 2 5; 3 6].
  3. Final Answer:

    B = [1 4; 2 5; 3 6] -> Option A
  4. Quick Check:

    Transpose swaps rows and columns = [1 4; 2 5; 3 6] [OK]
Quick Trick: Transpose flips rows and columns values [OK]
Common Mistakes:
  • Mixing elements order
  • Not swapping rows and columns
  • Confusing output format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes