wp = 2*pi*100e3;
Qp = 10;

C1 = 1e-9;   C2 = C1;
R1 = 1.6e3;  R2 = R1;
G  = 2.9;

f =  logspace(4, 6, 500);
w =  2*pi*f;
s =  tf('s');

e = [ 1, 1.1 ];
c = [ 'b'; 'g'; 'r' ];
leg = [];

for i = 1 : length(e)
    R1eff = e(i) * R1
    weff = 1/sqrt(R1eff*C1*R2*C2)
    Qeff = weff / ((1/(R1eff*C1)) + (1/(R2*C1)) + (1-G)/(R2*C2))
    e(i)
    h = 1/(1 + s/(weff*Qeff) + (s/weff)^2);
    resp = freqresp(h, w);
    resp = resp(1, :);
    semilogx(f, 20*log10(abs(resp)), c(i));
    hold on;
end

title('Sallen-Key Choice 1 Magnitude Response');
xlabel('Frequency  [Hz]');
ylabel('Magnitude  [dB]');
legend('nominal R1', 'R1 10% large');
fixfig;
