References:
http://stackoverflow.com/questions/5887366/matlab-spectrogram-params
http://stackoverflow.com/questions/22661758/how-to-improve-the-resolution-of-the-psd-using-matlab
由于实际信号通常是非定常的,我们只能假设其在10ms的时间段内是定常的,并在此基础上对短的定常信号求PSD或者能谱。窗函数的作用就是将原始的信号分割成一段段可以计算PSD和能谱的短信号,并且保证了周期结构的连续性、避免了能量泄漏(原因解释)。不同的窗函数具有不同的特性(main lobe widths and side lobe amplitudes),应用时根据实际情况需要取舍。
采用了窗函数后,窗口两侧位置的信息就会减少(因为窗函数两端为零值),这就需要滑动窗口的位置来解决,也就是说窗口重叠(overlapping)的作用就是使得对分割后信号的分析更可靠。一般来说,Noverlapping取33%~50%。窗口之间重叠得越多,图像越平滑(blurred);反之则更粗糙(blocky)。
简单比较一下Hanning窗和Blackwell-Harris窗:从下面的图3可以看出,Hanning窗的主瓣较窄,分析结果的频率分辨率则较高,但旁瓣能量泄漏也更明显;Blackwell-Harris窗则相反。
Window
functions
Some of the common windows are Hanning, Hamming, Blackman, Blackman-Harris, Kaiser-Bessel, etc. Here's a small sample of the different windows:
Why there
are so many different window functions is because each of these
have very different spectral properties and have different main
lobe widths and side lobe amplitudes. There is no
such thing as a free lunch: if you want good frequency resolution
(main lobe is thin), your sidelobes become larger and vice versa.
You can't have both. Often, the choice of window function is
dependent on the specific needs and always boils down to making a
compromise.
Noverlap
when you use a window function,
you have less information at the tapered ends. So, one way to fix
that, is to use sliding windows with an overlap as shown below. The
idea is that when put together, they approximate the original
sequence as best as possible (i.e., the bottom row should be as
close to a flat value of 1 as possible). Typical values vary
between 33% to 50%, depending on the application.
PS. since the window function is close to zero at its edges, the data points at the edges do not contribute as much as points in the middle of a window. With half-overlapping windows this effect is much smaller. Making the overlap bigger than 50% is useless, you will get more averages, but since you will use the same points many times, this does not add any extra information. Just stick to 50%. (from reference web 2 )
Comparison
You get a cleaner estimate if you use overlap. That is to say, the larger the overlap, the more blurred the spectrogram will look because the segments will be overlapped to a greater degree. The smaller the overlap the more "blocky" the spectrogram will appear because each Fourier transform uses less and less common waveform samples.
You can also observe the trade-off between main lobe width and side lobe amplitude that I mentioned earlier. Hanning has a thinner main lobe (prominent line along the skew diagonal), resulting in better frequency resolution, but has leaky sidelobes, seen by the bright colors outside. Blackwell-Harris, on the other hand, has a fatter main lobe (thicker diagonal line), but less spectral leakage, evidenced by the uniformly low (blue) outer region.
PS.
The non-stationarity of the signal (where statistics are a function of time, Say mean, among other statistics, is a function of time) implies that you can only assume that the statistics of the signal are constant over short periods of time. There is no way of arriving at such a period of time (for which the statistics of the signal are constant) exactly and hence it is mostly guess work and fine-tuning. Both these methods above are short-time methods of operating on signals.
Say that your signal is
non-stationary. Also assume that it is stationary only for about
10ms or so. To reliably measure statistics
like
You can
imagine it like this:
1. Take the first 10ms of the signal.
2. Window it with the windowing function.
3. Compute statistic only on this 10ms portion.
4. Move the window by 5ms (assume length of overlap).
5. Window the signal again.
PSS (from reference web 2)
Usually make the length of the fft (third
argument to pwelch) the same as the window length. The only case
you want to have this different is when you
use
If you use it like this, there are a few rules to remember:
·
·
·
·
·