-4
喜欢,我们可以考虑下面的矩阵: enter image description here如何打印矩阵的所有索引,这是矩阵的最大数目?
现在我想显示矩阵的最大无的所有索引,而不是仅仅只有一个指标矩阵的最大的。
喜欢,我们可以考虑下面的矩阵: enter image description here如何打印矩阵的所有索引,这是矩阵的最大数目?
现在我想显示矩阵的最大无的所有索引,而不是仅仅只有一个指标矩阵的最大的。
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]
请没有截图,而不是写代码* *成问题本身。 –
在你的问题中包括你的代码和问题的明确定义。 – miken32