Calling Column of a Matrix | Linear Algebra using Python

Linear Algebra using Python | Calling Column of a Matrix: Here, we are going to learn how to call columns of a matrix in Python?
Submitted by Anuj Singh, on May 14, 2020

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. Matrix is the key to linear algebra. All the linear algebra revolves around matrices. Columns are the heart of a Matrix. From column space to null space of a matrix is based on Columns. Therefore, whenever we have to go for Column operations, then we have to call our columns.

The following code shows how to call a whole column of a matrix.

Python code for calling column of a matrix

# Linear Algebra Learning Sequence
# Calling Column of a Matrix

import numpy as np

# Use of np.array() to define a matrix
V = np.array([[1,2,3],[2,3,5],[3,6,8],[323,623,823]])
print("--The Matrix-- \n",V)

j = int(input("Enter j (column number) : "))

# Printing the V[i][j] element of the matrix
ln = len(V)
for i in range(ln):
    print("Component [",i,"] [",j,"] :", V[i][j-1])   

Output:

--The Matrix-- 
 [[  1   2   3]
 [  2   3   5]
 [  3   6   8]
 [323 623 823]]
Enter j (column number) : 2
Component [ 0 ] [ 2 ] : 2
Component [ 1 ] [ 2 ] : 3
Component [ 2 ] [ 2 ] : 6
Component [ 3 ] [ 2 ] : 623


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.