【发布时间】:2018-04-25 04:35:42
【问题描述】:
我有 matlab 代码,我想将其更改为 python 代码。 为此,我想知道如何在 python 中获取直方图最大值的索引
在matlab中很容易得到索引
例如
array1 = [0 1 2 2 3 4 4 4 4 5 6 6 7 8 9]
a1 = hist(array1,max(array1)-min(array1))
[value , index] = max(a1)
u=[index-2:1:index+2]
array_matrix = a1(u)
% then value = 4 , index = 5
但是我怎样才能进入python?
我知道有 matplotlib 和 numpy 可以获取直方图。 但我不知道如何获得它的最大值和索引。
【问题讨论】:
标签: python matplotlib indexing max histogram