Written and maintained by CASRAI Editorial Board
Last updated
Transpose in MATLAB swaps the rows and columns of an array. Use A.' (or transpose(A)) for a plain transpose and A' (or ctranspose(A)) for the complex conjugate transpose. For real-valued data the two give identical results; they differ only when the data are complex.
This guide is for researchers and analysts who need to flip a vector or matrix, fix a size mismatch, or understand why ' changed the sign of imaginary parts. It also answers the common questions about the @ symbol, 2 x 2 transposes, A*A', and transpose versus inverse.
What transpose is used for in research
Transposing converts a row vector to a column vector and a matrix of size m-by-n to n-by-m. In research code this typically comes up when preparing data for matrix products (see matrix multiplication in MATLAB), when a function expects observations in rows and variables in columns, and when working with complex-valued signals where the conjugate matters. For the wider set of matrix operations, see creating and transforming a matrix in MATLAB.
Install or access
The transpose operators are part of core MATLAB. MATLAB is obtained from MathWorks (mathworks.com); licensing for your institution is handled through MathWorks or your campus software office. The syntax below follows the MathWorks reference pages listed under Sources.
Step by step: transpose in MATLAB
MATLAB transpose: the two operators
- Create an array:
A = magic(4); - Apply the plain (nonconjugate) transpose:
B = A.'or equivalentlyB = transpose(A). Each element A(i,j) moves to B(j,i). - Apply the complex conjugate transpose:
C = A'orC = ctranspose(A). MathWorks describesctransposeas an alternate way to runA'that is rarely used. - Check the result with
size(B).
Transpose on MATLAB for a row or column vector
A vector is a one-row or one-column array, so the same operators apply: v = [1 2 3] is 1-by-3, and v.' is the 3-by-1 column [1; 2; 3]. Transposing again returns the original shape.
Transpose of a 2 x 2 matrix
To find the transpose of a 2 x 2 matrix, write its rows as columns. With A = [1 2; 3 4], A.' is [1 3; 2 4]. The diagonal (1 and 4) stays in place; the off-diagonal entries 2 and 3 swap. The same result comes from A' because A is real.
Output and how to read it
The documentation example A = magic(4); B = A.' returns an array whose rows are the columns of A. For complex input the operators diverge. Take z = [1+2i, 3-1i] (1-by-2):
| Expression | Result | Imaginary signs |
|---|---|---|
z.' |
2-by-1: 1+2i, 3-1i |
Unchanged |
z' |
2-by-1: 1-2i, 3+1i |
Negated |
MathWorks states that A.' does not affect the sign of the imaginary parts, while A' negates them. When no complex elements are present, A' produces the same result as A.'; for logical or non-numeric inputs, ctranspose and transpose also produce the same result.
Which operator should you use?
| Your data | Operator | Why |
|---|---|---|
| Real numeric or logical | Either | Identical output |
| Complex, you only want rows and columns swapped | .' |
Imaginary parts keep their sign |
| Complex, you want the conjugate transpose | ' |
Imaginary parts are negated |
| Non-numeric arrays | Either | MathWorks: same result for non-numeric input |
Using .' everywhere is the safe habit if you never want an accidental conjugate.
Troubleshooting
Size mismatch when multiplying vectors
Two row vectors of the same length cannot be multiplied with *: [1 2 3]*[4 5 6] fails because a 1-by-3 times a 1-by-3 has mismatched inner dimensions. Transposing one fixes it: [1 2 3]*[4 5 6]' returns 32 (1-by-3 times 3-by-1). The reverse, [1 2 3]'*[4 5 6], returns a 3-by-3 matrix.
Imaginary parts changed sign unexpectedly
You used ' on complex data. Switch to .' or transpose.
Is A*A’ always the identity matrix?
No. A times its transpose is generally not the identity. For A = [1 2; 3 4], A*A' is [5 11; 11 25], which is symmetric but not the identity. A*A' equals the identity only for special matrices, namely orthogonal matrices in the real case, such as rotation matrices.
What is the difference between transpose and inverse?
Transpose rearranges entries; the inverse is the matrix that multiplies with A to give the identity. Transpose works on any array shape; inv(X) computes the inverse of a square matrix X only. For A = [1 2; 3 4], A.' is [1 3; 2 4] while inv(A) is [-2 1; 1.5 -0.5]. MathWorks also notes that it is seldom necessary to form the explicit inverse: x = A\b is recommended over x = inv(A)*b for solving linear systems, and inv loses accuracy when X is badly scaled or nearly singular.
What does @ do in MATLAB?
The @ symbol is not a transpose. In MATLAB’s operator list it creates anonymous functions and function handles (and calls superclass methods). For example f = @(x) x.' defines a function that transposes its input, so f([1 2 3]) returns the column [1; 2; 3]. The transpose symbols are .' and '; * is matrix multiplication.
Free alternatives
| Tool | Plain transpose | Conjugate transpose |
|---|---|---|
| MATLAB | A.', transpose(A) |
A', ctranspose(A) |
| GNU Octave | x.' |
x', ctranspose(A); for real arguments the same as the transpose operator |
GNU Octave documents the same two operators and a ctranspose function equivalent to A'. For Python and R, see NumPy transpose and R transpose with t(); for reshaping in SAS, see PROC TRANSPOSE in SAS.
FAQ
What is the difference between .’ and ‘ in MATLAB?
.' is the nonconjugate transpose; ' is the complex conjugate transpose. They match for real data.
How do I transpose a vector in MATLAB?
Apply v.' to turn a row into a column or a column into a row.
Is there a function form?
Yes: transpose(A) for A.' and ctranspose(A) for A'.
Sources
- MathWorks, transpose, .’ (read 2026-11-07)
- MathWorks, ctranspose, ‘ (read 2026-11-07)
- MathWorks, inv (read 2026-11-07)
- MathWorks, MATLAB operators and special characters (read 2026-11-07)
- GNU Octave documentation, Arithmetic operators (read 2026-11-07)







