# Matlab-Matrix - Transpose

#### Artificial Neural Network and Machine Learning using MATLAB

54 Lectures 4 hours

#### Machine Learning for Data Science using MATLAB

Featured

62 Lectures 9 hours

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

>>
```