EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab Transpose
 

Matlab Transpose

Updated March 6, 2023

Matlab Transpose

 

 

Introduction to Matlab Transpose

Transpose is used in mathematics to interchange the rows and columns of the input matrix. So, if we have a 2 x 3 matrix as our input, the transpose function will give us a 3 x 2 matrix as the output. In Matlab, we use the ‘transpose function’ to compute the transpose of a matrix or a vector. For a vector with ‘n’ elements, the transpose function gives a ‘n x 1’ matrix as output (‘n’ rows and 1 column).

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax of transpose function:

T = transpose (M)

T = M.’

Explanation:

  • T = transpose (M) is used to compute the transpose of the input matrix ‘M’, i.e., it will interchange the rows and columns of the matrix ‘M’.
  • T = M.’ is another way of computing the transpose. It will give the same output as the above syntax.

Examples of Matlab Transpose

Given below are the examples of Matlab Transpose:

Example #1

In this example, we will use the transpose function to compute the transpose of a 2 x 2 real matrix.

Below are the steps to be followed:

  • Initialize the input matrix.
  • Pass this input matrix as an argument to the transpose function.

Code:

M = [6 -5; 1 6] [Initializing the 2 x 2 input matrix]

T = transpose (M)
[Using the transpose function to compute the transpose of the input matrix]

Input:

Matlab Transpose 1

Output:

Before transpose:

Matlab Transpose 2

After transpose:

Matlab Transpose 3

As we can see in the output, the transpose function has interchanged the rows and columns of our input matrix.

Example #2

In this example, we will use the transpose function to compute the transpose of a 3 x 3 real matrix.

Below are the steps to be followed:

  • Initialize the input matrix.
  • Pass this input matrix as an argument to the transpose function.

Code:

M = [2 -1 4; 1 16 2; 0 -4 3] [Initializing the 3 x 3 input matrix]

T = transpose (M)
[Using the transpose function to compute the transpose of the input matrix]

Input:

Matlab Transpose 4

Output:

Before transpose:

Matlab Transpose 5

After transpose:

Matlab Transpose 6

As we can see in the output, the transpose function has interchanged the rows and columns of our input matrix.

In the above 2 examples, our input matrix was of real elements.

Next, let us take an example where our input matrix will have complex elements as well.

Example #3

In this example, we will use the transpose function to compute the transpose of a 3 x 3 complex matrix.

Below are the steps to be followed:

  • Initialize the input matrix with complex elements.
  • Pass this input matrix as an argument to the transpose function.

Code:

M = [2+3i 1-4i 1; 1+3i 0 3-2i; 0 3 2] [Initializing the 3 x 3 input matrix with complex elements]

T = transpose (M)
[Using the transpose function to compute the transpose of the input matrix]

Input:

3 x 3 complex matrix

Output:

Before transpose:

Before

After transpose:

After

As we can see in the output, the transpose function has interchanged the rows and columns of our input complex matrix.

In the above 3 examples, we have used a square matrix as our input.

Next, we will use a non-square matrix as input to the transpose function.

Example #4

In this example, we will use the transpose function to compute the transpose of a 2 x 3 real matrix.

Below are the steps to be followed:

  • Initialize the input matrix.
  • Pass this input matrix as an argument to the transpose function.

Code:

M = [1 6 4; 1 4 -2] [Initializing the 2 x 3 input matrix]

T = transpose (M)
[Using the transpose function to compute the transpose of the input matrix]

Input:

2 x 3 real matrix

Output:

Before transpose:

Before transpose

After transpose:

Matlab Transpose 12

As we can see in the output, the transpose function has interchanged the rows and columns of our non-square input matrix.

In the above 4 examples, we have used a matrix as our input to the transpose function.

Next, we will use the transpose function to compute the transpose of a vector input.

Example #5

In this example, we will use the transpose function to compute the transpose of a vector with 5 elements.

Below are the steps to be followed:

  • Initialize the input vector with 5 elements.
  • Pass this input vector as an argument to the transpose function.

Code:

M = [8 -11 4 5 7] [Initializing the input vector with 5 elements]

T = transpose (M)
[Using the transpose function to compute the transpose of the input vector] Please note that since our input has 5 columns and 1 row, our output will have 5 rows and 1 column.

Input:

of a vector with 5 elements

Output:

Before transpose:

Before

After transpose:

Matlab Transpose 15

As we can see in the output, the transpose function has interchanged our input vector rows and columns.

Conclusion

We use the transpose function to compute the transpose of a matrix, i.e., interchange its rows and columns. Transpose function can be used for both real and complex matrices. For a vector input, the transpose function will convert a number of elements in the vector as a number of rows of the output.

Recommended Articles

This is a guide to Matlab Transpose. Here we discuss the introduction and examples of Matlab transpose for better understanding. You may also have a look at the following articles to learn more –

  1. What is Matlab?
  2. Matlab limit
  3. Plot graph Matlab
  4. Absolute Value Matlab

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW