EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
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).

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

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
SPSS Course Bundle - 14 Courses in 1 | 5 Mock Tests
34+ Hours of HD Videos
14 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
MICROSOFT AZURE Course Bundle - 15 Courses in 1 | 12 Mock Tests
62+ Hour of HD Videos
15 Courses
12 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
HADOOP Course Bundle - 32 Courses in 1 | 4 Mock Tests
125+ Hour of HD Videos
32 Courses
4 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
INFORMATICA Course Bundle - 7 Courses in 1
47+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Popular Course in this category
MATLAB Course Bundle - 5 Courses in 1 | 3 Mock Tests
 11+ Hours of HD Videos
5 Courses
3 Mock Tests & Quizzes
  Verifiable Certificate of Completion
  Lifetime Access
4.5
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

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

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

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more