I'm trying to run a simulation in MATLAB to model two low pass filters. It's an active low-pass filter visualized by the schematic below:


simulate this circuit – Schematic created using CircuitLab

The only part I'm focused on right now is the feedback circuit with the capacitor and the resistor. I'm trying to see how changing the capacitor would adjust the low pass filter while keeping the resistance the same.

For just this part, I've managed to get the following equation for the low pass filter, and I simplified it by focusing on the filter part assuming that R can be used as part of the gain provided by the amplifier:

\$\frac{R}{1 + j*2*pi*f*R*C}\$ ---> \$\frac{1}{1 + j.*2.*pi.*f.*R.*C}\$

Using the simplified model, I used MATLAB to write plots for the magnitude and bode plot of the filters with their respective capacitances, but something seems strange with the bode plot. The frequency at the -3 dB point doesn't match up with the 1/sqrt(2) point in the magnitude plot. I know that this is a really simple question, but I just can't seem to figure out why the bode plot doesn't match up. Might there be something I'm not taking into account? My code is show below:

clc; clear all; close all;  f = 1:1000:(1e9);

Ra = 470;             Ca = 3.*(10.^-12);
AA = 1./(1+j.*2.*pi.*f.*Ra.*Ca);
magAA = abs(AA);      bodeAA = 0-20.*log(magAB);

Rb = 470;               Cb = 6.*(10.^-12);
AB = 1./(1+j.*2.*pi.*f.*Rb.*Cb);
magAB = abs(AB);        bodeAB = 0-20.*log(magAB);

%Graph Lines for -3 dB and 1/sqrt(2)
line3 = ones(size(f)); line3 = line3 .*-3;   
line2 = ones(size(f)); line2 = line2 .*(1./sqrt(2));

figure(1); %Plot the filter Magnitude
plot(f,magAA);      title('MagPlot 3pF');   hold on; plot(f,line2,'--r');

figure(2); %Plot the filter magnitude
plot(f,magAB);      title('MagPlot 6pF');   hold on; plot(f,line2,'--r');

figure(3);  %Plot the filter bode plot
plot(f,bodeAA);     title('Bode Plot 3pF'); hold on; plot(f,line3,'--r');

figure(4);  %Plot the filter bode plot
plot(f,bodeAB);     title('Bode Plot 6pF'); hold on; plot(f,line3,'--r');
  • \$\begingroup\$ Well, first of all log is the inverse of e^x you want log10. Also why not use transfer functions? H = tf(1,[RC 1]); bode(H) \$\endgroup\$ – sstobbe May 31 '17 at 13:28
  • \$\begingroup\$ Thanks for your reply. I didn't catch that with the log statement, just thought it was log base 10 and not natural log. Changing it to log10 really helped; though there's a slight variation with the frequencies, it seems negligible given how close they are. Regarding the other functions, I just didn't know about them. \$\endgroup\$ – user101402 May 31 '17 at 13:38
  • \$\begingroup\$ No problem, also the help files in matlab seem to be actually written by technical individuals and I have always found them to be helpful \$\endgroup\$ – sstobbe May 31 '17 at 13:43
  • \$\begingroup\$ Thanks to @sstobbe for the comment. Thanks to it, it really helped get me on the right track. I've been using log, which is natural log. I should have been using log10, which is log base 10. Making the change solved my issue with the frequency; though there is some slight variation between the frequencies of the magnitude and bode plots, they seem close enough that they can be negligible (a difference between 112.608 MHz in Bode and 112.8758 MHz in Magnitude). \$\endgroup\$ – user101402 May 31 '17 at 13:44
  • \$\begingroup\$ I recommend also using semilogx instead of plot and possibly grid on and grid minor to show the minor grids. \$\endgroup\$ – Chris M. May 31 '17 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.