Challenge - 5 Problems
Matrix Transpose Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this matrix transpose code?
Consider the following MATLAB code that transposes a matrix. What will be the output?
MATLAB
A = [1 2 3; 4 5 6]; B = A'; disp(B);
Attempts:
2 left
💡 Hint
Remember that the transpose flips rows and columns.
✗ Incorrect
The transpose operator (') swaps rows and columns. The original matrix A has 2 rows and 3 columns, so B will have 3 rows and 2 columns with elements flipped accordingly.
🧠 Conceptual
intermediate1:30remaining
What does the transpose operator (') do to a matrix?
In MATLAB, what is the effect of applying the transpose operator (') to a matrix?
Attempts:
2 left
💡 Hint
Think about how rows and columns change positions.
✗ Incorrect
The transpose operator swaps the rows and columns of the matrix, effectively flipping it over its main diagonal.
🔧 Debug
advanced2:00remaining
What happens when transposing a cell array with ' operator?
What happens if you try to transpose a cell array using the ' operator in MATLAB?
MATLAB
C = {1, 2; 3, 4};
D = C';Attempts:
2 left
💡 Hint
Check MATLAB documentation for transposing cell arrays.
✗ Incorrect
No error occurs. The ' operator transposes cell arrays by swapping rows and columns, just like for numeric matrices. For this C, D = {1, 3; 2, 4}.
❓ Predict Output
advanced2:30remaining
What is the output of transposing a complex matrix with ' operator?
Given the matrix with complex numbers, what is the output of the transpose operation?
MATLAB
M = [1+1i, 2-1i; 3+0i, 4+4i]; T = M'; disp(T);
Attempts:
2 left
💡 Hint
The ' operator does conjugate transpose for complex matrices.
✗ Incorrect
In MATLAB, the ' operator performs conjugate transpose, which flips the matrix and takes the complex conjugate of each element.
❓ Predict Output
expert3:00remaining
What is the output of transposing a sparse matrix?
Consider this sparse matrix and its transpose. What is the output of the following code?
MATLAB
S = sparse([1 3 4], [2 1 3], [10 20 30], 4, 4); ST = S'; full(ST)
Attempts:
2 left
💡 Hint
Transpose swaps row and column indices in sparse matrices.
✗ Incorrect
Transposing a sparse matrix swaps the row and column indices of nonzero elements. Using full() converts it to a full matrix for display.