Why do I have negative dB values after converting PSD output to dB?
22 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 3 Nov 2019
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
Answers (0)
See Also
Categories
Find more on Parametric Spectral Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!