Finding frequencies corresponding to some gain on Band Pass Filter Bode Plot
2 views (last 30 days)
Show older comments
Good evening,
I'm trying to use this code to find specific frequencies on a band pass filter bode plot, given the gain value, but since I have 2 frequencies for each gain value, I'm getting errors saying that the sample points from the bode plot must be in ascending order.
I can do it the other way (find gain given the frequency), but is there a way for me to get the 2 frequencies for a given gain value?
Thanks.
wo = 2*pi*120;
Bw = 2*pi*12;
num=[Bw 0];
den=[1 Bw wo^2];
sys=tf(num, den)
bode(sys)
[mag, phase, wout]=bode(sys);
mag=squeeze(mag);
phase=squeeze(phase);
MaxGain = max(20*log10(mag))
Gain120hz = interp1(wout, 20*log10(mag), wo)
w0 = interp1(20*log10(mag), wout, MaxGain)
0 Comments
Accepted Answer
Mathieu NOE
on 10 Nov 2020
wo = 2*pi*120;
Bw = 2*pi*12;
num=[0 Bw 0];
den=[1 Bw wo^2];
w = logspace(log10(wo/2),log10(wo*2),400); % w vector log and symetrical around 120 Hz
sys=tf(num, den)
bode(sys,w)
[mag, phase, wout]=bode(num,den,w);
% mag=squeeze(mag);
% phase=squeeze(phase);
[MaxGain,ind] = max(20*log10(mag));
MaxGain
w0 = wout(ind);
f0 = w0/2/pi
Gain120hz = interp1(wout, 20*log10(mag), wo)
% w0 = interp1(20*log10(mag), wout, MaxGain); % no : X vector may not be
% uniform
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!