Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Finding the maximum element from a matrix with Python numpy.argmax()

import numpy as np    

a = np.matrix([[1,2,3,33],[4,5,6,66],[7,8,9,99]])

print(np.argmax(a))  # 11, which is the position of 99
print(np.argmax(a[:,:]))  # 11, which is the position of 99
print(np.argmax(a[:1]))  # 3, which is the position of 33
print(np.argmax(a[:,2]))  # 2, which is the position of 9
print(np.argmax(a[1:,2]))  # 1, which is the position of 9
Source by itsmycode.com #
 
PREVIOUS NEXT
Tagged: #Finding #maximum #element #matrix #Python
ADD COMMENT
Topic
Name
9+6 =