"""
Create by 2015-10-25
@author: zhouheng
In this function you can get the position of the element
that you want in the matrix.
"""
import numpy as np
def getPositon():
a = np.mat([[2, 5, 7, 8, 9, 89], [6, 7, 5, 4, 6, 4]])
raw, column = a.shape# get the matrix of a raw and column
_positon = np.argmax(a)# get the index of max in the a
print _positon
m, n = divmod(_positon, column)
print "The raw is " ,m
print "The column is ", n
print "The max of the a is ", a[m , n]
getPositon()
这是求的矩阵中最大元素的所在的行与列的python程序,希望对大家有帮助
python中取得矩阵中最大元素的位置
最新推荐文章于 2024-07-05 03:30:28 发布