我是python的初学者,正在阅读教程,但无法获得正确的结果。
我想知道哪里出了问题!
binFreq = np.arange(N / 2 + 1) * float(fs) / N
squaredMX = np.square(mX)
lowBandIdx0 = np.where(binFreq > 0)[0][0]
lowBandIdx3000 = np.where(binFreq < 3000)[0][-1]
highBandIdx3000 = np.where(binFreq > 3000)[0][0]
highBandIdx10000 = np.where(binFreq < 10000)[0][-1]
lowBandSqMX = squaredMX[:,lowBandIdx0:lowBandIdx3000+1]
highBandSqMX = squaredMX[:,highBandIdx3000:highBandIdx10000+1]
engEnv = np.zeros((numFrames, 2))
engEnv[:, 0] = 10*np.log10(np.sum(lowBandSqMX, 1))
engEnv[:, 1] = 10*np.log10(np.sum(highBandSqMX, 1))
我特别想了解这些行的作用:
lowBandIdx3000 = np.where(binFreq < 3000)[0][-1]
highBandIdx10000 = np.where(binFreq < 10000)[0][-1]
答案 0 :(得分:0)
这给出了一组索引,其中条件binFreq < 10000
为True。我不确定您到底想达到什么目的,但希望能有所帮助!您可以像这样做一个小测试,以显示我的意思。
import numpy
a = numpy.array([4,2,3,1,5])
b = numpy.where(a<3)
print(b)#[1,3]