EGR 224/Active Filter

From PrattWiki
Revision as of 12:18, 7 April 2020 by DukeEgr93 (talk | contribs)
Jump to navigation Jump to search

The following page provides some supplemental information for the Active Filters lab for EGR 224L. It has been updated to Spring, 2020.

Requirements

You will need access to MATLAB with the Signal Processing Toolbox. You can use MATLAB on the Duke system if you connect via VPN. Then use a terminal program to connect to Duke. Run the command

xeyes &

to make sure graphics are working.

If you installed MATLAB on your own computer but do not have the Signal Processing Toolbox:

  • Go to the HOME tab
  • Find and click on "Add-Ons"
  • Search for Signal Processing
  • Click on the link for the Signal Processing Toolbox
  • Sign in to install if need be
  • Install

Script from 7.4.2

clear
load DukeFightSong
%% Filter constants
R = 10000;   C = 50e-9;

%% Experimental Transfer Function
[EstH, EstF] = tfestimate(SoundIn, SoundOut, [], [], [], samplerate);
EstMag = abs(EstH);
EstOmega = EstF*2*pi;
%% Analytical Transfer Function
s = tf([1 0], [1]);
H = 1 / (1 + s * R * C);
[HMag, HPhase, HOmega] = bode(H, {1, max(EstOmega)});
HMag = squeeze(HMag);
%% Make plot
figure(1); clf
semilogx(EstOmega, 20*log10(EstMag), 'b-')
hold on
semilogx(HOmega, 20*log10(HMag), 'r-')
hold off
xlabel('\omega, rad/s'); ylabel('|H|, dB')
legend('Estimates', 'Theoretical', 'location', 'best')