[英]Using the heapq function 'nlargest' to find the peaks of an FFT and their corresponding frequencies in python
[英]How do I find the Peaks and the corresponding frequencies from the FFT?
例如,如果你有兩個數組
a = [1,2,3] #where you want to find the peak
b = [4,5,6] #the corresponded frequency
你可以找到 a 的最大值
max_a = max(a)
index = a.index(max_a)
frequency = b[index]
完整代碼:
max_list = []
for _ in range(9):
max_a = max(a)
index = a.index(max_a)
frequency = b[index]
max_list.append((max_a,frequency)) #value of that a and that frequency
a.pop(index)
b.pop(index)
最終產品將是
max_list = [(a,b),(c,d),...]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.