Why do I have negative dB values after converting PSD output to dB?

조회 수: 31 (최근 30일)
Louise Wilson
Louise Wilson 2019년 11월 3일
댓글: Louise Wilson 2019년 11월 3일
I'm using acoustic data which I am in the process of producing spectrograms for. At the moment I am working with one .wav file at a time. I load in the file, apply a calibration correction, perform the spectrogram function and then plot the output of this using surf. In the plotting process, I convert the PSD to decibels. My understanding is that once I do this, all of my values should be positive, is that the case? As, when I check the output of the data, I get a negative value as the minimum value -35.0339. Can anyone explain why this would be??
directory=('Y:\SoundTrap\Noises\Noises_5103_SepOct'); %folder where wav files are
%Load in files of interest:
wavfile='5103.190901150236.wav';
%Get full filename:
wavfilename=fullfile(directory, wavfile);
%Input variables for audioread:
fs=144000;
tlo=4.0; %select only part of data and so remove cal.tone
thi=119.0;
nlo=fs*tlo; %multiply fs by tlo to get starting point
nup=fs*thi; %do the same for end point
%Input variables for spectrogram:
nfft=fs;
window=fs;
overlap=window/2;
%Get calibration info:
SN=strsplit(wavfile, '.');
SN1=char(SN(1));
serialNo=str2num(SN1);
cal=176.5;
%Read in file and apply calibration:
[xbit,fs]=audioread(wavfilename, [nlo nup]); %read in wav
xbit=detrend(xbit); %remove DC offset
cal=power(10,cal/20); %calculate calibration value
calxbit=xbit*cal; %apply calibration
%Perform FFT and plot:
f1=figure; %produces empty figure to plot in
[cal,F,T,P] = spectrogram(calxbit,window,overlap,nfft,fs,'yaxis');
%P is a matrix representing PSD of each segment
surf(T,F,10*log10(P),'edgecolor','none');
%plots output of spectrogram
%10log10 converts PSD output to dB
%Look at dB values:
dbvals=10*log10(P);
mindb=min(dbvals,[],'all');
maxdb=max(dbvals,[],'all');
  댓글 수: 4
Walter Roberson
Walter Roberson 2019년 11월 3일
If there is a segment which is fairly quiet (little noise) then it seems to me the PSD for the segment could be small. PSD of roughly 0.00032 would give you the -35 dB
Louise Wilson
Louise Wilson 2019년 11월 3일
This is great to know, thank you. I just wanted to be sure it wasn't an error. Thanks!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Estimation에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by