Determine -3db gain on Freq- gain plot
古いコメントを表示
Hello,
I got some freq-gain data from a filter and I am trying to determine -3db gain on the plot and get its frequency.
I am trying "interp1" but it comes with only one point.
How can I get the other one ?
Thank you
freq=t1.f;
noise=t1.noise;
gain=t1.gain;
figure
plot(freq,noise)
xlabel('Frequency')
ylabel('noise')
figure
[Max_gain,index1]=max(gain);
freq_max=freq(index1);
Gain_3db=Max_gain-3;
freq_3db=interp1(gain,freq,Gain_3db)
plot(freq,gain,'b')
ylabel('gain')
xlabel('Frequency')
hold on
plot(freq_3db,Gain_3db,'r*')
採用された回答
その他の回答 (4 件)
cr
2022 年 11 月 18 日
0 投票
interp1() outputs linearly interpolated values that you are asking for. if Gain_3db is a scalar value the output is a scalar. The output you get this way gives you the freq at which gain fell by 3dB from its max value.
Perhaps the other value you are looking for is the start freq.
This is also not a great way to do what you seem to be looking for. It only works if gain values are monotonic.
I think this code can help you, it is something I often use. It is not most efficient, but it works.
Please have a look at the example:
clear
clc
close all
num = 1;
den = [1 1];
g = tf(num,den);
[mag, phase, w] = bode(g);
magdb = squeeze(20*log10(mag));
semilogx(w,magdb);
ylim([-15, 0]);
grid on;
ind = find(magdb>=-3,1,'last');
% find two nearest points
P1w = [w(ind), w(ind+1)];
P2m = [magdb(ind), magdb(ind+1)];
% Find slope and intercept
c = [[1; 1] P1w(:)]\P2m(:);
% y = ax+b;
a = c(2);
b = c(1);
% Find angular frequency where magdb is -3 dB
w_3db = (-3-b)/a;
% Check if this is the case
mag_3db = a*w_3db+b;
hold on
plot(w_3db, mag_3db,'ro');
text(w_3db, mag_3db, [' -3 dB point,', newline, 'w = ', num2str(w_3db), 'rad/s'])
Moussa Ihab
2022 年 11 月 18 日
0 投票
1 件のコメント
Star Strider
2022 年 11 月 18 日
It would help to have your data. Please post the frequency and gain vectors.
カテゴリ
ヘルプ センター および File Exchange で Digital Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



