我是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]发布于 2018-10-15 06:15:31
这给出了一个索引数组,其中条件binFreq < 10000为真。我不确定你到底想要达到什么目的,但希望这能有所帮助!你可以做一个像这样的小测试来显示我在说什么。
import numpy
a = numpy.array([4,2,3,1,5])
b = numpy.where(a<3)
print(b)#[1,3]https://stackoverflow.com/questions/52805215
复制相似问题