(i,j)矩阵中的元素| 使用Python的线性代数

Prerequisite: Linear Algebra | Defining a Matrix

先决条件: 线性代数| 定义矩阵

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In some of the problems, we need to use a particular element of the matrix. In the python code, we will first define a matrix and then we will call its (i,j) element.

线性代数是使用向量空间和矩阵的线性方程组的数学分支。 在某些问题中,我们需要使用矩阵的特定元素。 在python代码中,我们将首先定义一个矩阵,然后将其称为(i,j)元素。

    i = row number
    j = column number
    Objective: A[i][j] ? 

从矩阵固定(i,j)元素的Python代码 (Python code for fidning (i,j) Element from a Matrix)

# Linear Algebra Learning Sequence
# Defining a matrix using numpy

import numpy as np

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

# Finding the ith and jth entry in matrix
i = int(input("Enter i (row number) : "))
j = int(input("Enter j (column number) : "))

# Printing the V[i][j] element of the matrix
print("Component [",i,"] [",j,"] :", V[i-1][j-1])

Output:

输出:

--The Matrix-- 
 [[1 2 3]
 [2 3 5]
 [3 6 8]]
Enter i (row number) : 3
Enter j (column number) : 2
Component [ 3 ] [ 2 ] : 6


翻译自: https://www.includehelp.com/python/i-j-element-from-a-matrix.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值