HOWTO · MATLAB
MATLAB Transpose
One can take the transpose of a matrix using the transpose() and ctranspose() function in MATLAB.
On this page
In MATLAB, use transpose(A) or A.' to swap the rows and columns without changing complex values. Use ctranspose(A) or A' to swap rows and columns and conjugate complex values. For real-valued arrays, both operations give the same result; for complex-valued arrays, choose the operation that matches the calculation you need.
Calculate the Transpose of a Matrix Using the transpose() Function in MATLAB
The transpose() function returns a vector or matrix with its rows and columns exchanged. A row vector becomes a column vector, and a matrix with m rows and n columns becomes one with n rows and m columns. The function does not conjugate complex entries. The operator .' performs the same ordinary transpose, so either form is useful when writing MATLAB code.
This Octave-compatible MATLAB example uses a real matrix and displays the result with disp. It runs successfully and prints the matrix with its rows and columns exchanged.
A = [1 2 3; 4 5 6];
T = transpose(A);
disp(T)
1 4
2 5
3 6
The first row of A becomes the first column of T, and the second row becomes its second column. For an ordinary transpose using the operator, write T = A.';. The dot before the apostrophe matters: it selects a transpose that does not conjugate complex entries. This form and transpose(A) are equivalent for the operation shown. See the MATLAB transpose documentation for function details.
Calculate the Complex Conjugate Transpose of a Matrix Using the ctranspose() Function in MATLAB
The ctranspose() function exchanges rows and columns and takes the complex conjugate of each entry. In a complex number, conjugation changes the sign of its imaginary part: for example, 1 + 2i becomes 1 - 2i. MATLAB’s apostrophe operator, A', performs this complex-conjugate transpose. This differs from the ordinary transpose for complex-valued data, so use the operator or function deliberately when the input may be complex.
This separate Octave-compatible MATLAB example shows the operation on a complex row vector. It runs successfully and displays the conjugated values in a column.
A = [1+2i 2+3i];
T = ctranspose(A);
disp(T)
1 - 2i
2 - 3i
The result is a column vector whose entries are 1 - 2i and 2 - 3i: the row becomes a column, and each imaginary component changes sign. You can write the same operation as T = A';. For a real-valued vector or matrix, conjugation leaves every entry unchanged, so ctranspose(A) and transpose(A) return equal values. For complex-valued data they generally differ; use transpose() or .' when only row-column exchange is intended, and ctranspose() or ' when conjugation is part of the desired result. See the MATLAB ctranspose documentation for more details.