Transposing a Vector or Matrix


Normally Transposing a vector or matrix is method to swapped the value with each other.
Like ,
suppose we have one matrix 2*2. When we perform trasposing that time column value swapped in raw and waw value swapped in column.


You need to transposing a vector or matrix.


For the transposing we use T method

Transposing Matrix</4>

# Load library
import numpy as np

# Create matrix
matrix = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])

# Transpose matrix



array([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])

Discussion :

Transposing is a common operation in linear algebra where the column and row indices of each element are swapped.
One nuanced point that is typically overlooked outside of a linear algebra class is that,
technically, a vector cannot be transposed because it is just a collection of values.

Transpose vector

import numpy as np

np.array([1, 2, 3, 4, 5, 6]).T



array([1, 2, 3, 4, 5, 6])

However, it is common to refer to transposing a vector as converting a row vector to
a column vector (notice the second pair of brackets) or vice versa:

Transpose vector with array

import numpy as np

np.array([[1, 2, 3, 4, 5, 6]]).T





Leave a Comment

Your email address will not be published.

Latest Blog