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

18 views (last 30 days)
Louise Wilson
Louise Wilson on 3 Nov 2019
Commented: Louise Wilson on 3 Nov 2019
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:
%Get full filename:
wavfilename=fullfile(directory, wavfile);
%Input variables for audioread:
tlo=4.0; %select only part of data and so remove cal.tone
nlo=fs*tlo; %multiply fs by tlo to get starting point
nup=fs*thi; %do the same for end point
%Input variables for spectrogram:
%Get calibration info:
SN=strsplit(wavfile, '.');
%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
%plots output of spectrogram
%10log10 converts PSD output to dB
%Look at dB values:
Louise Wilson
Louise Wilson on 3 Nov 2019
This is great to know, thank you. I just wanted to be sure it wasn't an error. Thanks!

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by