2016-08-22 2 views
-4

우리가 매트릭스 다음 고려할 수처럼 : enter image description here매트릭스의 최대 인덱스 인 매트릭스의 모든 인덱스를 어떻게 인쇄해야합니까?

지금 나는 모든 매트릭스없이 최대의 인덱스와 행렬의 최대의 단지 하나의 인덱스를 표시합니다.

+3

제발 아무 스크린 샷이 대신 질문 자체 *에 코드 * 물품. –

+1

질문에 명확한 코드 정의와 코드를 포함하십시오. – miken32

답변

1
import numpy as np 

mat = np.array([[2,3,2], [7,7,6], [2,7,3]]) 
print(mat) 

max_indices = np.where(mat == np.amax(mat)) 
print(max_indices) 

index_max = mat[max_indices] 
print(index_max) 

출력 :

[[2 3 2] 
[7 7 6] 
[2 7 3]] 
(array([1, 1, 2]), array([0, 1, 1])) # first array: x-axis, second: y-axis 
[7 7 7]