Skip to content

Instantly share code, notes, and snippets.

@tobin
Created November 21, 2013 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobin/7585340 to your computer and use it in GitHub Desktop.
Save tobin/7585340 to your computer and use it in GitHub Desktop.
Plot the frequency response (Bode plot) of an ideal active twin-T notch
% Plot the frequency response of an ideal active twin-T notch, versus
% bootstrap feedback gain \alpha.
%
% Tobin Fricke <tobin.fricke@ligo.org>
% 2013-11-21
% Pick the color map (to make the plot pretty)
cm = jet();
% Choose the frequency axis
f = logspace(log10(0.1), log10(10), 501);
omega = 2*pi*f;
s = 1i * omega;
% Set the resonant frequency
omega0 = 2*pi*1;
% Choose the values of alpha to plot
alphas = 0:0.2:1;
alphas(end) = [];
% Do the plot
for alpha=alphas
% Compute the transfer function
H = (s.^2 + omega0^2) ./ (s.^2 - 4*s*omega0*(alpha-1) + omega0^2);
% Plot it
color = interp1(linspace(0, 1, size(cm,1)), cm, alpha);
subplot(2,1,1);
semilogx(f, db(H), '.-', 'color', color);
grid on
hold all
subplot(2,1,2);
semilogx(f, angle(H)*180/pi, '.', 'color', color);
grid on
hold all
end
% More plotting stuff
subplot(2,1,1);
ylim([-60 10]);
caxis([0,1]);
%colorbar
legend(cellfun(@(x) sprintf('\\alpha = %0.2f', x), num2cell(alphas), ...
'UniformOutput', false), 'Location', 'SouthEast');
hold off
ylabel('dB');
title('frequency response of an ideal active twin-T notch, versus bootstrap feedback gain \alpha');
subplot(2,1,2);
ylabel('degrees');
xlabel('normalized frequency (\omega/\omega_0)');
set(gca, 'ytick', 45*(-4:4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment