Find and plot 3dB and 6dB downpoints of spectral peak frequency in a PSD

11 views (last 30 days)
I have a PSD and find its peak with:
Pyy, fyy]= periodogram(filterLow_hyd1,[],[],fs);
[pk, loc] = findpeaks(Pyy,'Npeaks',1,'SortStr','descend');
Peak_frequency = fyy(loc);
pkdB = 10 * log10(pk);
How do I find its 3dB/6dB downpoints?

Accepted Answer

Star Strider
Star Strider on 31 Oct 2015
This is robust in the event you want to find the -3dB and -6dB points on more than one peak:
fyy = linspace(0, 50, 250); % Create Data
Pyy = 0.5*exp(-(fyy-15).^2) + 0.3*exp(-(fyy-40).^2); % Create Data
[pk,loc] = findpeaks(Pyy,'Npeaks',1,'SortStr','descend');
db3c = 10^(-3/10); % Relative Magnitude At -3dB
db6c = 10^(-6/10); % Relative Magnitude At -6dB
ofst = 10;
for k1 = 1:length(pk)
varmtx = [Pyy(loc(k1)-ofst:loc(k1)); fyy(loc(k1)-ofst:loc(k1)); Pyy(loc(k1):loc(k1)+ofst); fyy(loc(k1):loc(k1)+ofst)];
dBpts(k1,1:2) = interp1(varmtx(1,:), varmtx(2,:), pk(k1)*[db6c db3c], 'linear','extrap');
dBpts(k1,3:4) = interp1(varmtx(3,:), varmtx(4,:), pk(k1)*[db6c db3c], 'linear','extrap');
end
figure(1)
plot(fyy, Pyy)
hold on
for k1 = 1:length(pk)
plot(dBpts(k1,:), pk(k1)*[db6c db3c db6c db3c], 'r+')
end
hold off
grid
for k1 = 1:length(pk)
fprintf(1, '\n\t-6dB frequencies = %.3f, %.3f\n', dBpts(k1,[1 3]))
fprintf(1, '\n\t-3dB frequencies = %.3f, %.3f\n', dBpts(k1,[2 4]))
end
  4 Comments
Butterflyfish
Butterflyfish on 31 Oct 2015
Beauty! Thanks a million, that works perfectly. Sorry for giving the data only afterwards.
Star Strider
Star Strider on 31 Oct 2015
Thank you! My pleasure!
Your data only necessitated a couple tweaks in my code, one of which (that it needs row vectors) I probably should have mentioned at the outset. The change in ‘ofst’ is the sort of tweak necessary when dealing with real-world data.

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!