2016-12-11 56 views
0

我一直在研究一個項目,我必須獲得我在PlotlyJS中繪製的最大值,我需要獲取.wav文件的頻率並打印與該頻率相關的音符。 http://samcarcagno.altervista.org/blog/basic-sound-processing-julia/ 我一直在關注這篇文章,但這隻給你頻率的光譜圖。爲了獲得基頻,我改變了y的值。如何獲取JULIA中的一個地塊的最大值?

plot(scatter(;x=freqArray/1000, y=p), 
Layout(xaxis_title="Frecuencia (kHz)", 
     xaxis_zeroline=false, 
     xaxis_showline=true, 
     xaxis_mirror=true, 
     yaxis_title="Intensidad (dB)", 
     yaxis_zeroline=false, 
     yaxis_showline=true, 
     yaxis_mirror=true)) 

That's the plot 請幫助我,我不知道如何你有兩個耦合向量獲得頻率

+2

'maximum(freqArray)'不好嗎? –

+3

討論劇情的最大值沒有意義。您需要的是您放入圖中的數據的最大值。 –

回答

0

p包含強度的值,並且freqArray包含匹配的頻率。對於所有指數i,您的繪圖顯示(freqArray[i],p[i])定義的(x,y)點序列。

您可以使用indmax(p)返回p具有最大值的索引。然後,您可以通過在該索引處索引freqArray來查找頻率。

julia> p = rand(200); 
     freqArray = 5:5:1000; 

julia> idx = indmax(p) 
114 

julia> p[idx] # this is the maximum value 
0.9968329198539723 

julia> freqArray[idx] # and this is its frequency 
570 
相關問題