How to use pspectrum() function

75 ビュー (過去 30 日間)
Elinor Ginzburg
Elinor Ginzburg 2020 年 9 月 15 日
回答済み: Madhav Thakker 2020 年 9 月 18 日
Hello,
I want to create a power spectrum vs frequency plot of an audio signal I have. I tried using the following code:
[speech, f1] = audioread('outputTSNRcut.wav');
[noise, f2] = audioread('input2noise.wav');
[speechInput,fspeech] = pspectrum(speech, f1);
[noiseInput, fnoise] = pspectrum(noise, f2);
fig1 = figure;
plot(fspeech, abs(speechInput), 'b');
xlabel('Frequency (Hz)');
ylabel('Power Spectrum (dB)');
title('Speech Spectral Density');
fig2 = figure;
plot(fnoise, abs(noiseInput), 'r');
xlabel('Frequency (Hz)');
ylabel('Power Spectrum (dB)');
title('Noise Spectral Density');
which produced the following power spectrum plot:
The problem is that the audio is a speech recording, thus I'm expecting the power spectrum to be somwhere around 20 - 40 dB, perhaps more, but certintly not under 1 dB! I'm not sure what have I done wrong, I tried to follow exactly the pspectrum documantation. I'd appreciate it if someone could correct me.
Thank you.

採用された回答

Madhav Thakker
Madhav Thakker 2020 年 9 月 18 日
Hi Elinor, the ppsptectrum function does not return the output directly in dB to be plotted. According to the documentation,
For the plot, the function converts p to dB using 10*log10(p)
  • You can use ppspectrum with no output arguments to plot the spectral estimate in the current window.
ppspectrum(speech, f1);
  • Another way is to manually convert p to dB.
Hope this helps.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by