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

조회 수: 9 (최근 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에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by