我正在尝试在python中运行specgram
函数,但是我收到了错误:
ValueError:len(窗口)必须与所选轴的x形状相同。
当我在spectrogram
或specgram
命令中运行相同的确切变量时,在Matlab中它运行正常。这是为什么?
这是python代码(x64
是一个长度为38,022的数组,StackOverflow不允许上传它,我也不知道如何上传它):
from matplotlib import mlab
import numpy as np
nfft = 4096
fs = 44100
step = .001
nwind = np.fix (np.multiply([0.002,0.004,0.008,0.016,0.032,0.064],fs))
noverlap = np.round (np.subtract(nwind,(step*fs)) )
han = np.hanning(nwind[5])
han_norm = han * np.sqrt(np.divide(len(han) , np.sum(np.square(han))))
[y64,f64,t64] = mlab.specgram( x64,NFFT=nfft, Fs=fs, window=han_norm, noverlap=noverlap[5],mode='complex')