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

11 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2015-10-31
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 个评论
Butterflyfish
Butterflyfish 2015-10-31
Beauty! Thanks a million, that works perfectly. Sorry for giving the data only afterwards.
Star Strider
Star Strider 2015-10-31
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by