English 中文(简体)
Matlab-Matrix - Transpose
  • 时间:2024-11-03

Matlab-Matrix - Transpose


Previous Page Next Page  

The transpose operation switches the rows and columns in a matrix. It is represented by a single quote( ).

Example

Consider following example −


a = [ 10 12 23 ; 14 8 6; 27 8 9]
b = a 

Output

The execution in MATLAB gives the following output −


>> a = [ 10 12 23 ; 14 8 6; 27 8 9]
b = a 

a =

   10  12  23
   14   8   6
   27   8   9
 
b =

   10  14  27
   12   8   8
   23   6   9
 
>>

The transpose() function

You can also make use of the transpose() function to get the transpose of a matrix.

Example

Consider the following example for use of transpose() function −


a = [ 10 12 23 ; 14 8 6; 27 8 9]
b = transpose(a)

Output

You will get the following output −


>> a = [ 10 12 23 ; 14 8 6; 27 8 9]
b = transpose(a)

a =

   10  12  23
   14   8   6
   27   8   9
 
b =

   10  14  27
   12   8   8
   23   6   9
 
>>
Advertisements