我正在把我的代码从python转换成objective c。
内部plotgram.matmlab绘图函数I在fft前看到3个重要函数:result = stride_windows(x, NFFT, noverlap, axis=0)
result = detrend(result, detrend_func, axis=0)
result, windowVals = apply_window(result, window, axis=0,
return_window=True)
result = np.fft.fft(result, n=pad_to, axis=0)[:numFreqs, :]
我试着调试以了解每一个的目的。例如,我有一个输入数组:
^{pr2}$
第一次功能后,跨步窗(这是为了防止漏水?),如果NFFT=4,noverlap=2,则:x = [ [1,3,5,7,9],
[2,4,6,8,10],
[3,5,7,9,11],
[4,6,8,10,12]
]
detrend之后没有任何变化(我理解fft之前的detrend)
在应用窗口内(我不明白这一步):xshape = list(x.shape)
xshapetarg = xshape.pop(axis) // =4
windowVals = window(np.ones(xshapetarg, dtype=x.dtype))
//result of 4 elements [0.0, 0.75, 0.75, 0.0]
xshapeother = xshape.pop() // =5
otheraxis = (axis+1) % 2 // =1
windowValsRep = stride_repeat(windowVals, xshapeother, axis=otheraxis)
// result windowValsRep = [
[ 0. ,0. ,0. ,0. ,0. ,],
[0.75, 0.75, 0.75, 0.75,
[0.75, 0.75, 0.75, 0.75,
[ 0. ,0. ,0. ,0. ,0. ,]
]
然后乘以xwindowValsRep * x
现在x = [
[ 0. , 0. , 0. , 0. , 0. ],
[ 1.5 , 3 , 4.5 , 6. , 7.5 ],
[ 2.25, 3.75 , 5.25 , 6.75 , 8.25 ],
[ 0. , 0. , 0. , 0. , 0. ]
]
最后一个是fft,我知道fft只需要一个数组,但这里它处理的是二维数组。为什么?在result = np.fft.fft(x, n=pad_to, axis=0)[:numFreqs, :]
有谁能一步一步地给我解释一下为什么数据需要在fft之前进行这样的处理?在
谢谢