Power scaling with spectrogram

10 vues (au cours des 30 derniers jours)
Peter
Peter le 13 Mai 2013
Commenté : star yen le 28 Jan 2016
Dear all, I'm processsing a voltage trace (mV) with spectrogram (trace of a couple of minutes, hamming window 1 s, 0.5 s noverlap, 1 s nfft window, 20.000 Hz sampling rate) in order to determine the frequency content which works very well overall. But I do not really understand how I can interprete the power color code. What is the exact scaling of the color code and how can I derive the proper axis notation? I'm really looking forward to your help. All the best, Peter

Réponse acceptée

Peter
Peter le 14 Mai 2013
Thanks - here is my piece of code with a test noise representing my signal in mV. I'm interested in the frequency range between 2 and 40 Hz to be displayes. My question: what unit does the power scaling display, so what can I put on the colorbar as proper scaling unit? How can I deduce the proper scaling unit from the input units? Looking forward to your advice. All the best, Peter
% generate a test signal (supposed in mV)
x=0:1/200:200*pi;
sinus=sin(x)*0.1;
lo=-0.6;
hi=0.2;
noise=lo + (hi-lo) * rand(size(x));
testSignal=sinus+noise;
% display test signal and calculate spectrogram
sampleRate=20000; % sampling rate
t1=20000; % 1s time window
t2=round(0.5*t1);
% calculate spectrogram
[temp,tempF,tempT,tempP]=spectrogram(testSignal,hamming(t1),...
t2,t1,sampleRate,'yaxis');
% find the start point of 2 Hz
tempFstart=find(tempF>=2); tempFstart=tempFstart(1);
% find the end point of 40 Hz
tempFstop=find(tempF<=40); tempFstop=tempFstop(length(tempFstop));
figure
subplot(2,1,1)
plot(testSignal)
axis tight
title('original trace')
ylabel('mV','FontName','Arial','FontSize',8);
subplot(2,1,2)
tempxP=(abs(tempP(tempFstart:tempFstop,:)));
surf(tempT,tempF(tempFstart:tempFstop),(tempxP), ...
'FaceColor','interp','EdgeColor','none'); % pcolor als test
view(0,90)
axis tight
title('spectrogram - power units?')
set(gca, 'GridLineStyle','none','box','off');
ylabel('Hz','FontName','Arial','FontSize',8);
colorbar
  2 commentaires
Honglei Chen
Honglei Chen le 14 Mai 2013
You are using the last output, so it is power density, i.e., mV^2/Hz.
star yen
star yen le 28 Jan 2016
I key "help spectrogram" in Matlab, and find this statement: % NOTE: This is the same as calling spectrogram with no outputs. [y,f,t,p] = spectrogram(x,256,250,F,1E3,'yaxis'); surf(t,f,10*log10(abs(p)),'EdgeColor','none');
So, 10*log10(abs(p)) is the answer!!(p is power spectral density) But I don't know why p is not equal to s.^2 (I tried several times..)

Connectez-vous pour commenter.

Plus de réponses (2)

Honglei Chen
Honglei Chen le 13 Mai 2013
Modifié(e) : Honglei Chen le 13 Mai 2013
Not sure if I understand your question correctly, but you can see the value represented by the color by issuing
>> colorbar
in the command line.
The value is power in dB scale. So if your signal is in volts, then it's in watt.

Peter
Peter le 13 Mai 2013
Well, not exactly. Of course I have a colorbar displaying the range from 0 to 19*10(-4). But what does this mean (µV²/ Hz or something else)? Looking forward to your advice. All the best, Peter
  1 commentaire
Honglei Chen
Honglei Chen le 13 Mai 2013
I updated the answer above. It's power in dB scale by default. I'm not sure what 19*10(-4) is, do you have a reproduction step?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Time-Frequency Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by