
- MATLAB - Home
- MATLAB - Overview
- MATLAB - Features
- MATLAB - Environment Setup
- MATLAB - Editors
- MATLAB - Online
- MATLAB - Workspace
- MATLAB - Syntax
- MATLAB - Variables
- MATLAB - Commands
- MATLAB - Data Types
- MATLAB - Operators
- MATLAB - Dates and Time
- MATLAB - Numbers
- MATLAB - Random Numbers
- MATLAB - Strings and Characters
- MATLAB - Text Formatting
- MATLAB - Timetables
- MATLAB - M-Files
- MATLAB - Colon Notation
- MATLAB - Data Import
- MATLAB - Data Output
- MATLAB - Normalize Data
- MATLAB - Predefined Variables
- MATLAB - Decision Making
- MATLAB - Decisions
- MATLAB - If End Statement
- MATLAB - If Else Statement
- MATLAB - If…Elseif Else Statement
- MATLAB - Nest If Statememt
- MATLAB - Switch Statement
- MATLAB - Nested Switch
- MATLAB - Loops
- MATLAB - Loops
- MATLAB - For Loop
- MATLAB - While Loop
- MATLAB - Nested Loops
- MATLAB - Break Statement
- MATLAB - Continue Statement
- MATLAB - End Statement
- MATLAB - Arrays
- MATLAB - Arrays
- MATLAB - Vectors
- MATLAB - Transpose Operator
- MATLAB - Array Indexing
- MATLAB - Multi-Dimensional Array
- MATLAB - Compatible Arrays
- MATLAB - Categorical Arrays
- MATLAB - Cell Arrays
- MATLAB - Matrix
- MATLAB - Sparse Matrix
- MATLAB - Tables
- MATLAB - Structures
- MATLAB - Array Multiplication
- MATLAB - Array Division
- MATLAB - Array Functions
- MATLAB - Functions
- MATLAB - Functions
- MATLAB - Function Arguments
- MATLAB - Anonymous Functions
- MATLAB - Nested Functions
- MATLAB - Return Statement
- MATLAB - Void Function
- MATLAB - Local Functions
- MATLAB - Global Variables
- MATLAB - Function Handles
- MATLAB - Filter Function
- MATLAB - Factorial
- MATLAB - Private Functions
- MATLAB - Sub-functions
- MATLAB - Recursive Functions
- MATLAB - Function Precedence Order
- MATLAB - Map Function
- MATLAB - Mean Function
- MATLAB - End Function
- MATLAB - Error Handling
- MATLAB - Error Handling
- MATLAB - Try...Catch statement
- MATLAB - Debugging
- MATLAB - Plotting
- MATLAB - Plotting
- MATLAB - Plot Arrays
- MATLAB - Plot Vectors
- MATLAB - Bar Graph
- MATLAB - Histograms
- MATLAB - Graphics
- MATLAB - 2D Line Plot
- MATLAB - 3D Plots
- MATLAB - Formatting a Plot
- MATLAB - Logarithmic Axes Plots
- MATLAB - Plotting Error Bars
- MATLAB - Plot a 3D Contour
- MATLAB - Polar Plots
- MATLAB - Scatter Plots
- MATLAB - Plot Expression or Function
- MATLAB - Draw Rectangle
- MATLAB - Plot Spectrogram
- MATLAB - Plot Mesh Surface
- MATLAB - Plot Sine Wave
- MATLAB - Interpolation
- MATLAB - Interpolation
- MATLAB - Linear Interpolation
- MATLAB - 2D Array Interpolation
- MATLAB - 3D Array Interpolation
- MATLAB - Polynomials
- MATLAB - Polynomials
- MATLAB - Polynomial Addition
- MATLAB - Polynomial Multiplication
- MATLAB - Polynomial Division
- MATLAB - Derivatives of Polynomials
- MATLAB - Transformation
- MATLAB - Transforms
- MATLAB - Laplace Transform
- MATLAB - Laplacian Filter
- MATLAB - Laplacian of Gaussian Filter
- MATLAB - Inverse Fourier transform
- MATLAB - Fourier Transform
- MATLAB - Fast Fourier Transform
- MATLAB - 2-D Inverse Cosine Transform
- MATLAB - Add Legend to Axes
- MATLAB - Object Oriented
- MATLAB - Object Oriented Programming
- MATLAB - Classes and Object
- MATLAB - Functions Overloading
- MATLAB - Operator Overloading
- MATLAB - User-Defined Classes
- MATLAB - Copy Objects
- MATLAB - Algebra
- MATLAB - Linear Algebra
- MATLAB - Gauss Elimination
- MATLAB - Gauss-Jordan Elimination
- MATLAB - Reduced Row Echelon Form
- MATLAB - Eigenvalues and Eigenvectors
- MATLAB - Integration
- MATLAB - Integration
- MATLAB - Double Integral
- MATLAB - Trapezoidal Rule
- MATLAB - Simpson's Rule
- MATLAB - Miscellenous
- MATLAB - Calculus
- MATLAB - Differential
- MATLAB - Inverse of Matrix
- MATLAB - GNU Octave
- MATLAB - Simulink
MATLAB - Transpose Operator
Transpose of a matrix is a very commonly used operation on a matrix.
What is Transpose of a matrix?
The transpose of a matrix is obtained by interchanging rows to columns and columns to rows.
Consider you have a matrix A of size 3x3 i.e 3 rows and 3 columns. The transpose of a matrix A is represented by letter T as a subscript to matrix A.
For example matrix A transpose will be AT or A. or A
Let us try one example
A = 1 2 3 4 5 6 7 8 9
The transpose of matrix A will be
AT = 1 4 7 2 5 8 3 6 9 OR A = 1 4 7 2 5 8 3 6 9
If you do transpose of the transpose matrix you will get the original matrix.
Let us start with the main Matrix A.
A = 1 2 3 4 5 6 7 8 9
The transpose of matrix A will be
AT = 1 4 7 2 5 8 3 6 9
Lets transpose it again and you should get the result which is equal to the original matrix we started with.
(AT)T = 1 2 3 4 5 6 7 8 9
So the equation (AT)T = A or (A) = A.
Transpose Method in Matlab
In matlab you can make use of the operator .' i.e A .' , also using ' i.e A' to find the transpose of the matrix or by using the transpose() method.
Syntax
T = A .' T = A' T = transpose(A)
The transpose() method or by using .' or ' will return the transpose of the matrix.
Example 1
Here I will make use of the operator .' to find the transpose of the matrix.
A = [1 2 3; 4 5 6; 7 8 9] T = A .'
On execution in matlab you get the following output
>> A = [1 2 3; 4 5 6; 7 8 9] >> T = A.' A = 1 2 3 4 5 6 7 8 9 T = 1 4 7 2 5 8 3 6 9 >>
Example 2
Using the operator '
A = [1 2 3; 4 5 6; 7 8 9] T = A '
On execution in Matlab you will get following output.
>> A = [1 2 3; 4 5 6; 7 8 9] T = A' A = 1 2 3 4 5 6 7 8 9 T = 1 4 7 2 5 8 3 6 9 >>
Example 3
Let us now make use of the transpose() method.
A = [1 2 3; 4 5 6; 7 8 9] T = transpose(A)
On execution the output is −
>> A = [1 2 3; 4 5 6; 7 8 9] T = transpose(A) A = 1 2 3 4 5 6 7 8 9 T = 1 4 7 2 5 8 3 6 9 >>
Transpose on Transpose of Matrix
Let us now try transpose on traponse of the matrix to make sure we get the original matrix back
Example 1
Using the operator (.')
A = [1 2 3; 4 5 6; 7 8 9] T = (A .').'
When the above code in executed in Matlab the output is as follows −
>> A = [1 2 3; 4 5 6; 7 8 9] T = (A .').' A = 1 2 3 4 5 6 7 8 9 T = 1 2 3 4 5 6 7 8 9 >>
Example 2
Using the transpose() method as shown below.
A = [1 2 3; 4 5 6; 7 8 9] T = transpose(A) Y = transpose(T)
On execution in matlab the output is −
>> A = [1 2 3; 4 5 6; 7 8 9] T = transpose(A) Y = transpose(T) A = 1 2 3 4 5 6 7 8 9 T = 1 4 7 2 5 8 3 6 9 Y = 1 2 3 4 5 6 7 8 9 >>
Transpose on Complex Matrix
Let us first construct a complex matrix as shown below.
A = [5 3 4-1i 3+2i; 0+4i 1-2i 5 5-1i] B = A.'
On execution in Matlab the output is −
>> A = [5 3 4-1i 3+2i; 0+4i 1-2i 5 5-1i] B = A.' A = 5 + 0i 3 + 0i 4 - 1i 3 + 2i 0 + 4i 1 - 2i 5 + 0i 5 - 1i B = 5 + 0i 0 + 4i 3 + 0i 1 - 2i 4 - 1i 5 + 0i 3 + 2i 5 - 1i >>
Transposing the matrix B again gives back the original matrix as shown below.
>> B = B.' B = 5.0000 + 0.0000i 3.0000 + 0.0000i 4.0000 - 1.0000i 3.0000 + 2.0000i 0.0000 + 4.0000i 1.0000 - 2.0000i 5.0000 + 0.0000i 5.0000 - 1.0000i >>
Difference between transpose operator (.') and (') ?
The operator .' follows non-conjugate transpose.
The operator ' follows conjugate transpose.
The above operators affect more on complex matrices.Since the operator .' is meant for non-conjugate transpose; it will make sure it does not affect the sign of the imaginary parts of the complex number. Whereas the sign of the imaginary parts of complex numbers will be affected when the operator(') is used.
Let us check the matrix with complex numbers and the output of transpose with (.') and (').
Let us consider the below matrix to test on both operators.
A = [5 3 4-1i 3+2i; 0+4i 1-2i 5 5-1i]
Conjugate transpose (')
The conjugate transpose of a matrix, also known as the Hermitian transpose or adjoint, is a mathematical operation that involves taking the transpose of a matrix and then replacing each element with its complex conjugate.
The complex conjugate of a complex number a + bi is formed by changing the sign of the imaginary part, resulting in a - bi. However, for real numbers, the complex conjugate remains unchanged.
>> A = [5 3 4-1i 3+2i; 0+4i 1-2i 5 5-1i] B = A' A = 5.0000 + 0.0000i 3.0000 + 0.0000i 4.0000 - 1.0000i 3.0000 + 2.0000i 0.0000 + 4.0000i 1.0000 - 2.0000i 5.0000 + 0.0000i 5.0000 - 1.0000i B = 5.0000 + 0.0000i 0.0000 - 4.0000i 3.0000 + 0.0000i 1.0000 + 2.0000i 4.0000 + 1.0000i 5.0000 + 0.0000i 3.0000 - 2.0000i 5.0000 + 1.0000i >>
Non-Conjugate transpose (.')
You will very rarely come across "Non-Conjugate transpose" term, it refers to a tranpose operatoon that does not consider the complex conjugate of the matrix elements.
>> A = [5 3 4-1i 3+2i; 0+4i 1-2i 5 5-1i] B = A.' A = 5.0000 + 0.0000i 3.0000 + 0.0000i 4.0000 - 1.0000i 3.0000 + 2.0000i 0.0000 + 4.0000i 1.0000 - 2.0000i 5.0000 + 0.0000i 5.0000 - 1.0000i B = 5.0000 + 0.0000i 0.0000 + 4.0000i 3.0000 + 0.0000i 1.0000 - 2.0000i 4.0000 - 1.0000i 5.0000 + 0.0000i 3.0000 + 2.0000i 5.0000 - 1.0000i >>
Another method that can be used to work on complex conjugate transpose is ctranpose().
Syntax
B = A' B = ctranspose(A)
This method is rarely used as you can directly go and make use of A . The ctranspose() is another alternative to give you the transpose of the matrix.
Let us see a few examples using ctranspose().
Example 1
Consider the following matrix.
A = [1 2 3; 4 5 6; 7 8 9] B = ctranspose(A)
On execution the output is −
>> A = [1 2 3; 4 5 6; 7 8 9] B = ctranspose(A) A = 1 2 3 4 5 6 7 8 9 B = 1 4 7 2 5 8 3 6 9 >>
Example 2
In this example will take a complex matrix as shown below.
A = [0-2i 4+1i;4+3i 0-2i] B = ctranspose(A)
On execution in matlab the output is −
>> A = [0-2i 4+1i;4+3i 0-2i] B = ctranspose(A) A = 0 - 2i 4 + 1i 4 + 3i 0 - 2i B = 0 + 2i 4 - 3i 4 - 1i 0 + 2i >>