Calculating the slope of a spectral slice (PSD)

6 views (last 30 days)
Ok, so I have managed to create some Thompson multitaper power spectral density estimates (PSD) and with some help, I was able to also plot the mean spectrum.
What I'm trying to do now is figure out the mean of the mean spectrum , that is the ' center of gravity (COG) ,' but I want to exclude the first 1000 Hz because the power from voicing skews the COG measures quite a bit.
Based on the mean, I want to calculate, two slopes : M1 from the 1000 Hz to the mean and M2, from the mean to the end of the frequency range . I am completely lost on how to do this. The script I have so far, is as follows:
a = wavread('sheppard_1');
b = wavread('sheppard_2');
c = wavread('sheppard_3');
d = wavread('sheppard_4');
e = wavread('sheppard_5');
f = wavread('sheppard_6');
g = wavread('sheppard_7');
h = wavread('sheppard_8');
i = wavread('sheppard_9');
fs = 44100;
[pxxa,fa] = pmtm(a, 3, length(a), fs);
[pxxb,fb] = pmtm(b, 3, length(b), fs);
[pxxc,fc] = pmtm(c, 3, length(c), fs);
[pxxd,fd] = pmtm(d, 3, length(d), fs);
[pxxe,fe] = pmtm(e, 3, length(e), fs);
[pxxf,ff] = pmtm(f, 3, length(f), fs);
[pxxg,fg] = pmtm(g, 3, length(g), fs);
[pxxh,fh] = pmtm(h, 3, length(h), fs);
[pxxi,fi] = pmtm(i, 3, length(i), fs);
meanpxx = (pxxa + pxxb + pxxc + pxxd + pxxe + pxxf + pxxg + pxxh + pxxi)/9;
h = [0.5, 0.5, 0.5];
figure1 = figure;
axes1 = axes('Parent',figure1,'YGrid','on',...
'XTickLabel',{'0','5','10','15','20'},...
'XTick',[0 5000 1e+004 1.5e+004 2e+004],...
'XGrid','on');
hold(axes1, 'all');
plot(fa, 10*log10(pxxa), 'color', h);
plot(fb, 10*log10(pxxb), 'color', h);
plot(fc, 10*log10(pxxc), 'color', h);
plot(fd, 10*log10(pxxd), 'color', h);
plot(fe, 10*log10(pxxe), 'color', h);
plot(ff, 10*log10(pxxf), 'color', h);
plot(fg, 10*log10(pxxg), 'color', h);
plot(fh, 10*log10(pxxh), 'color', h);
plot(fi, 10*log10(pxxi), 'color', h);
plot(fa, 10*log10(meanpxx), 'k-', 'LineWidth', 3);
grid on
title('Thompson Multitaper Power Spectral Density Estimate')
xlabel('Frequency(kHz)')
ylabel('Power/Frequency(dB/Hz)')
axis([0 22000 -150 -40])
hold off
I also want to calculate where the max peak is on the x-axis . I managed to calculate the y-value using the following:
z = max(max(meanpxx))
Which gives me z = 2.6765e-006
I then did the following to convert it into dB/Hz
z1 = 10*log10(z)
Which gives me z1 = -55.7243
How do I find the corresponding x-coordinate (aka the Frequency at the peak).
I attached a .zip with all the wav files I'm using and I attached an example plot of what I have and an example plot of what I want to create. Any help would be appreciated!

Accepted Answer

Star Strider
Star Strider on 3 Aug 2014
The max function will give you the index of the maximum value if you ask it:
[C,I] = max(A);
finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.
For the slope, I would use polyfit with a first-degree polynomial.
  14 Comments
Star Strider
Star Strider on 4 Aug 2014
Essentially, yes. It is just a bit more complicated than polyfit. I’d take time to explain it tonight, but I just deleted over 150 bot-posted spam messages from ‘jib ji’ over the last hour or so, and it’s posting faster than I can delete them. I’m tired (GMT-6 here).
That said, it’s probably relatively easy to set up regress to do what you want. After that, you can probably set up a function that would take your variables as arguments, call regress, and produce the values you want.
Phil
Phil on 4 Aug 2014
Sounds interesting, I will tinker with it for a bit before I go to bed.
I dunno why bots spam on here, one posted on a thread of mine before too.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!