如何使用Matlab提高PSD的分辨率 [英] how to improve the resolution of the PSD using Matlab

查看:237
本文介绍了如何使用Matlab提高PSD的分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有音频信号,可以通过Matlab读取,并使用pwelch来获取其PSD,这就是我正在使用的代码

I have and audio signal, which I read with Matlab, and use pwelch to get its PSD, here ist the code that I'm using

[x,Fs] = audioread('audioFile.wav');
x= x(:,1) %  mono
[xPSD,f] = pwelch(x,hamming(512),16,1024,Fs);
plot(f,xPSD);

因为FS=96000并且我仅在5khz以下的频率处被打扰,所以我只想计算该区域的PSD,并且还能够调整PSD的分辨率!任何想法都可以做到这一点!

since the FS=96000 and I'm only interrested in Frequencies bellow 5khz, I would like to calculate the PSD only for the area, and also being able to adjust the resolution of the PSD ! any idea hwo to do that !

推荐答案

使用pwelch计算PSD时,在光谱分辨率,平均数和所需数据量之间始终需要权衡取舍.我首选的使用方式是:

When calculating PSDs with pwelch, there is always a trade-off between spectral resolution, number of averages and the amount of data you need. My preferred way to use it is:

[psd_x, freq] = pwelch(x, hann(nfft), nfft/2, nfft, fsample);

您的代码有一些区别:

  1. 我更喜欢使用 hann 窗口,因为我对汉明窗有不好的经验,如果您的信号包含较大的DC分量,则效果不是很好.请参见此比较,该结果表明hann的推出要好得多,但代价是第一旁瓣稍高.

  1. I prefer to use hann windows, since I have bad experiences with hamming windows, they are not very good if your signal contains for example a large DC component. See this comparison, which shows that the roll-off of hann is much better, at the only cost of a slightly higher first sidelobe.

我使用重叠50%的窗口(通过使用noverlap = nfft/2),这样您可以充分利用数据".在您的情况下,窗口之间只有16/512 = 3%的重叠,并且由于窗口函数在其边缘处接近于零,因此边缘处的数据点的贡献不如窗口中间的点大.使用半重叠窗口时,此效果要小得多.使重叠部分大于50%是没有用的,您将获得更多的平均值,但是由于您将多次使用相同的点,因此不会添加任何额外的信息.坚持50%.

I use windows that overlap 50% (by using noverlap = nfft/2), in this way you 'get the most out of your data'. In your case, there is only 16/512 = 3% overlap between windows, and 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%.

我通常使fft(pwelch的第四个参数)的长度与窗口长度相同.唯一希望与众不同的情况是使用了用途有限的零填充.

I usually make the length of the fft (fourth argument to pwelch) the same as the window length. The only case you want to have this different is when you use zero-padding, which has limited use.

有一些简单的公式,在使用pwelch和类似函数时应该记住:

There are a few simple formulas, which you should memorize when working with pwelch and similar functions:

  • 光谱分辨率仅由窗口长度给出:df = 1 / t_window

单个窗口的长度为t_window = nfft / f_sample.

在窗口重叠的情况下,所需数据总量为t_total = t_window * (n_average + 1) / 2

With half-overlapping windows, the total amount of needed data is t_total = t_window * (n_average + 1) / 2

对于单面光谱,PSD的光谱仓数为nfft / 2.

For one-sided spectra, the number of spectral bins of the PSD is nfft / 2.

奈奎斯特:f_max = f_sample / 2

要获得合理的平滑频谱,我通常会使用20个平均值的数量级.将上面的方程式组合起来并填充所需的光谱分辨率,即可得出所需数据的总长度.或相反,如果只有有限的可用数据,则可以计算可获得的频率分辨率.

To get a reasonably smooth spectrum, I would typically use on the order of 20 averages. Combining the equations above and filling in the required spectral resolution then gives you the total length of data you need. Or the other way around, if you only have a limited amount of data available, you could calculate the frequency resolution you can obtain.

这篇关于如何使用Matlab提高PSD的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆