Create two matrices using the following code:
A = [1:3;4:6]; B = [1+1i, 1+2i, 1+3i];
A = 1 2 3 4 5 6
B = 1.0000 + 1.0000i 1.0000 + 2.0000i 1.0000 + 3.0000i
The transpose operation of a 2D matrix interchanges the row and column index of each element, therefore rows become columns and columns become rows.
MATLAB supports two types of transpose operations: complex conjugate transpose, and nonconjugate transpose. The difference is that the complex conjugate transpose negates the imaginary part of complex numbers in the input, while the other operation leaves them intact.
B = A' stores in
B the complex conjugate transpose of
B = A.' stores in
B the nonconjugate transpose of
% Complex conjugate transpose of A resultExample1 = A';
resultExample1 = 1 4 2 5 3 6
% Nonconjugate transpose of A resultExample2 = A.';
resultExample2 = 1 4 2 5 3 6
% Complex conjugate transpose of B resultExample3 = B';
resultExample3 = 1.0000 - 1.0000i 1.0000 - 2.0000i 1.0000 - 3.0000i
% Nonconjugate transpose of B resultExample4 = B.';
resultExample4 = 1.0000 + 1.0000i 1.0000 + 2.0000i 1.0000 + 3.0000i
I recommend the following books to learn more on matrix manipulation in MATLAB.
This book was the winner of a 2017 Textbook Excellence Award. The second chapter explains how to perform a wide list of operations on matrices, including the transpose operation.
MATLAB for Engineers (5th Edition)
This excellent book is especially oriented to engineers and scientists who want to learn MATLAB programming. Matrix manipulation is explained in the fourth chapter.
I also recommend the following pages in the MATLAB help documentation, and the other tutorials in this series.
doc ctranspose; doc transpose;
- How to Get the Size of a Matrix in MATLAB
- How to Get the Number of Elements in a Matrix in MATLAB
- How to Get the Number of Dimensions of a Matrix in MATLAB
- How to Reshape a Matrix in MATLAB
- How to Delete Items From a Matrix in MATLAB
- How to Transpose a 2D Matrix in MATLAB
- How to Transpose a Multidimensional Matrix in MATLAB
- How to Reverse a 2D Matrix in MATLAB
- How to Reverse a Multidimensional Matrix in MATLAB
I hope you have learned how to transpose a 2D matrix in MATLAB. The source code developed in this tutorial is available at this page.