Prerequisite: Linear Algebra | Defining a Vector
先决条件: 线性代数| 定义向量
Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a matrix in n-dimensional space with only one column. In the sequence of learning linear algebra using python, this is article 4. In some of the problems, we need to use a particular component of the vector.
线性代数是使用向量空间和矩阵的线性方程组的数学分支。 换句话说,向量是n维空间中只有一列的矩阵。 在使用python学习线性代数的过程中,这是第4条。在某些问题中,我们需要使用向量的特定分量。
For example: Let a vector a = [4, 9, 7], this is a 3 dimensional vector (x,y and z)
例如:令向量a = [4、9、7],这是3维向量(x,y和z)
So, if we need to call the yth component of the vector, we are talking about the corresponding value 9.
因此,如果我们需要调用向量的第 y 个分量,我们正在讨论的是对应的值9。
In the python code, we will first define a vector and then we will call its 4th component.
在python代码中,我们将首先定义一个向量,然后将其称为第4 个组件。
用于调用向量的第 i维分量的Python代码 (Python code for calling ith dimensional Component of Vector )
# Vectors in Linear Algebra
a = [3, 5, -5, 8]
print("Vector a = ", a)
# This is a 4-dimensional vector
i = int(input("type dimensional component you want to know: "))
print("Vector's", i," dimensional component = ", a[i-1])
Output
输出量
Vector a = [3, 5, -5, 8]
type dimensional component you want to know: 4
Vector's 4 dimensional component = 8
翻译自: https://www.includehelp.com/python/calling-ith-dimensional-component-of-vector.aspx