11/02/2023, 10:54                                                                                       Unit 3.
4: Transfer Functions — EG-247 Signals and Systems
                                                         Unit 3.4: Transfer Functions
               Contents
                          Colophon
                          Agenda
                          Transfer Functions for Circuits
                          Examples
                          Using Transfer Functions in MATLAB for System Analysis
                          Using Transfer Functions in Simulink for System Simulation
                          Reference
               The preparatory reading for this section is Chapter 4.4 [Karris, 2012] which discusses transfer
               function models of electrical circuits.
               Colophon
               An annotatable worksheet for this presentation is available as Worksheet 7.
                    The source code for this page is laplace_transform/4/transfer_functions.ipynb.
                    You can view the notes for this presentation as a webpage (HTML).
                    This page is downloadable as a PDF file.
               Agenda
                         Transfer Functions
                         A Couple of Examples
                         Circuit Analysis Using MATLAB LTI Transfer Function Block
                         Circuit Simulation Using Simulink Transfer Function Block
                    % Matlab setup
                    clear all
                    cd ../matlab
                    pwd
                    format compact
                    ans =
                        '/Users/eechris/code/src/github.com/cpjobling/eg-247-
                    textbook/laplace_transform/matlab'
               Transfer Functions for Circuits
               When doing circuit analysis with components defined in the complex frequency domain, the
               ratio of the output voltage         to the input voltage
                                                            Vout(s)         under zero initial conditions is of
                                                                                                           Vin(s)
               great interest.
               This ratio is known as the voltage transfer function denoted     :                                   Gv(s)
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                         1/7
11/02/2023, 10:54                                                                                       Unit 3.4: Transfer Functions — EG-247 Signals and Systems
                                                                                                Vout(s)
                                                                               Gv(s) =
                                                                                                 Vin(s)
               Similarly, the ratio of the output current        to the input current
                                                                                  Iout(s)                                      Iin(s)   under zero initial
               conditions, is called the cuurent transfer function denoted :                                     Gi(s)
                                                                                                Iout(s)
                                                                               Gi(s) =
                                                                                                 Iin(s)
               In practice, the current transfer function is rarely used, so we will use the voltage transfer
               function denoted:
                                                                                               Vout(s)
                                                                               G(s) =
                                                                                                Vin(s)
               Examples
               See Worksheet 7 for the worked solutions to the examples. We will work through these in
               class. Here I’ll demonstrate the MATLAB solutions.
               Example 6
               Derive an expression for the transfer function for the circuit below. In this circuit
                                                                                            G(s)                                                           Rg
               represents the internal resistance of the applied (voltage) source , and represents the                        vs       RL
               resistance of the load that consists of , and .                 RL L               C
               Sketch of Solution
                         Replace , , , and by their transformed (complex frequency) equivalents:
                                       vs(t) Rg RL L                       C
                              , , , and
                         Vs(s) Rg RL sL                         1/(sC)
                         Use the Voltage Divider Rule to determine as a function of             Vout(s)                                Vs(s)
                         Form by writing down the ratio
                                  G(s)                                                Vout(s)/Vs(s)
               Worked solution.
               Pencast: ex6.pdf - open in Adobe Acrobat Reader.
               Answer
                                                                      Vout(s)                  RL + sL + 1/sC
                                                      G(s) =                         =                                             .
                                                                        Vs(s)             Rg + RL + sL + 1/sC
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                         2/7
11/02/2023, 10:54                                                                                       Unit 3.4: Transfer Functions — EG-247 Signals and Systems
               Example 7
               Compute the transfer function for the op-amp circuit shown below in terms of the circuit
               constants , , , and .
                                 R1 R2 R3 C1                      C2
               Then replace the complex variable with , and the circuit constants with their numerical
                                                                          s          jω
               values and plot the magnitude
                                                                                               |Vout(jω)|
                                                                          |G(jω)| =
                                                                                                |Vin(jω)|
               versus radian frequency rad/s.            ω
               Sketch of Solution
                         Replace the components and voltages in the circuit diagram with their complex
                         frequency equivalents
                         Use nodal analysis to determine the voltages at the nodes either side of the 50K resistor
                         R3
                         Note that the voltage at the input to the op-amp is a virtual ground
                         Solve for          as a function of
                                        Vout(s)                                  Vin(s)
                         Form the reciprocal              G(s) = Vout(s)/Vin(s)
                         Use MATLAB to calculate the component values, then replace by .                                      s       jω
                         Plot on log-linear “paper”:
                                                                                       |G(jω)|
               Worked solution.
               Pencast: ex7.pdf - open in Adobe Acrobat Reader.
               Answer
                                            Vout(s)                                                         −1
                            G(s) =                         =                                                                                               .
                                             Vin(s)             R1 ((1/R1 + 1/R2 + 1/R3 + sC1) (sC2R3) + 1/R2)
               The Matlab Bit
               See attached script: solution7.m.
               Week 3: Solution 7
                    syms s;
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                         3/7
11/02/2023, 10:54                                                                                       Unit 3.4: Transfer Functions — EG-247 Signals and Systems
                    R1 = 200*10^3;
                    R2 = 40*10^3;
                    R3 = 50*10^3;
                    C1 = 25*10^(-9);
                    C2 = 10*10^(-9);
                    den = R1*((1/R1+ 1/R2 + 1/R3 + s*C1)*(s*R3*C2) + 1/R2);
                    simplify(den)
                    ans =
                    100*s*((7555786372591433*s)/302231454903657293676544 + 1/20000) + 5
               Simplify coefficients of s in denominator
                    format long
                    denG = sym2poly(ans)
                    denG =
                       0.000002500000000                       0.005000000000000                      5.000000000000000
                    numG = -1;
               Plot
               For convenience, define coefficients and :                    a         b
                    a = denG(1);
                    b = denG(2);
                                                                                                    −1
                                                                       G(jω) =
                                                                                               2
                                                                                           aω      − jbω + 5
                    w = 1:10:10000;
                    Gs = -1./(a*w.^2 - j.*b.*w + denG(3));
               Plot
                    semilogx(w, abs(Gs))
                    xlabel('Radian frequency w (rad/s')
                    ylabel('|Vout/Vin|')
                    title('Magnitude Vout/Vin vs. Radian Frequency')
                    grid
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                         4/7
11/02/2023, 10:54                                                                                        Unit 3.4: Transfer Functions — EG-247 Signals and Systems
               Using Transfer Functions in MATLAB for System
               Analysis
               Please use the file tf_matlab.m to explore the Transfer Function features provide by MATLAB.
               Open the file as a Live Script to see a nicely formatted document.
               Using Transfer Functions in Simulink for System
               Simulation
               The Simulink transfer function (Transfer Fcn) block implements a transfer function
               The transfer function block represents a general input output function
                                                                                                   N (s)
                                                                                 G(s) =
                                                                                                   D(s)
               and is not specific nor restricted to circuit analysis.
               It can, however be used in modelling and simulation studies.
               Example
               Recast Example 7 as a MATLAB problem using the LTI Transfer Function block.
               For simplicity use parameters                        , and
                                                                  R1 = R2 = R3 = 1 Ω F.                            C1 = C2 = 1
               Calculate the step response using the LTI functions.
               Verify the result with Simulink.
               The Matlab solution: example8.m
               MATLAB Solution
               From a previous analysis the transfer function is:
                                                Vout                                                      −1
                                G(s) =                   =
                                                 Vin           R1 [(1/R1 + 1/R2 + 1/R3 + sC1)(sR3C2) + 1/R2]
               so substituting the component values we get:
                                                                                    Vout                  −1
                                                                    G(s) =                     =
                                                                                                     2
                                                                                     Vin           s     + 3s + 1
               We can find the step response by letting                             vin(t) = u0(t)           so that      Vin(s) = 1/s          then
                                                                                                   −1              1
                                                                      Vout(s) =                                .
                                                                                            2
                                                                                           s    + 3s + 1           s
               We can solve this by partial fraction expansion and inverse Laplace transform as is done in the
               text book with the help of MATLAB’s residue function.
               Here, however we’ll use the LTI block.
               Define the circuit as a transfer function
                    G = tf([-1],[1 3 1])
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                          5/7
11/02/2023, 10:54                                                                                       Unit 3.4: Transfer Functions — EG-247 Signals and Systems
                    G =
                                -1
                      -------------
                      s^2 + 3 s + 1
                    Continuous-time transfer function.
               step response is then:
                    step(G)
               Simples!
               Simulink model
               See example_8.slx
                    open example_8
               Result
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                         6/7
11/02/2023, 10:54                                                                                       Unit 3.4: Transfer Functions — EG-247 Signals and Systems
               Let’s go a bit further by finding the frequency response:
                    bode(G), grid
               Reference
               See Bibliography.
   By Dr Chris P. Jobling
   © Copyright Swansea University (2019-2022).
   This page was created by Dr Chris P. Jobling for Swansea University .
file:///Users/eechris/code/src/github.com/cpjobling/eg-247-textbook/_build/html/laplace_transform/4/transfer_functions.html                                         7/7