필터 지우기
필터 지우기

How to use pspectrum() function

조회 수: 36 (최근 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 CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by