Transfer Function Analysis and Plotting using Matlab, Study notes of Electrical and Electronics Engineering

An example of determining the transfer function for a given circuit and plotting its magnitude and phase using matlab. It also discusses the concept of bode plots and how to sketch them manually. The script for determining the plot range based on the roots of the transfer function.

Typology: Study notes

Pre 2010

Uploaded on 10/01/2009

koofers-user-kw8
koofers-user-kw8 🇺🇸

10 documents

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Circuits II
EE221
Unit 5
Instructor: Kevin D. Donohue
Transfer Function, Complex Frequency, Poles and
Zeros, and Bode Plots
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Transfer Function Analysis and Plotting using Matlab and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Circuits II

EE

Unit 5

Instructor: Kevin D. Donohue

Transfer Function, Complex Frequency, Poles and

Zeros, and Bode Plots

Node Voltage Example ¾^

Perform phasor analysis to determine

v o

( t ) for

ω

=2. Since the

frequency of the source is not specified, leave impedances interms of

j^ ω

= s

¾^

Show that ¾^

Show

v^0

( t ) = .33cos(

t -9.

° ) V , when

ω

v ( s

t) = cos(

ω t

) V

2 Ω

4 Ω 0.5 F

2 H

  • v ( t ) o -

(^

)^

⎞⎟⎟⎠

⎛^ ⎜⎜⎝

⎞⎟ ⎠

⎛⎜ ⎝

−°

∠ + − ∠ = + +

=^

2

1

2 (^222)

2

(^33)

tan 90

9 ) (^3) ( ˆ ˆ 3 3 ˆ ˆ

ω^ ω

ω ω ω

s s

s o^

V V

s s

s

V V

Transfer Functions^ ¾

Definition:

A transfer function (TF) is a complex-valued

function of

ω

, such that the TF magnitude indicates the scaling

between the input and output magnitudes, and the TF phaseindicates the phase shifting between the input and outputphases. The transfer function indicates this relationship for allinput frequencies. ¾^

To find a transfer function, convert to impedance circuit, butleave the impedance values as functions of

j ω

= s.

Then solve for

the ratio of the phasor output divided by the phasor input.

Transfer Function Example Determine the transfer function for the circuit below, where the inputis^

v ( i

t ) and the output is

io

( t ).

Show transfer function is given by:

v ( ti

R ) 1

R^2

i C ( t )o ⎞⎟ ⎟⎠

⎛^ ⎜⎜⎝

⎞⎟⎟⎠

⎛⎜⎜⎝

=

2 1

2 1

2 1

0

1

ˆ ˆ )( ˆ

R CR

R R s

R CR

I V s H

i

Evaluating/Plotting TFs ¾^

The following Matlab commands can be used to plot the results of thelast TF. Let R

= 50kf

Ω, R

= 10ki

, R

=1.59kh

, C = 1

μF

Rf = 50e3; Ri = 10e3; Rh=1.59e3; C = 1e-6; f = [0:500]; % generate x-axis points s = j2pif; h = (1+Rf/Ri)s ./ (s + (1/(Rh*C)));

% Evaluate TF at every point

figure(1) % Plot Magnitude plot(f,abs(h)) xlabel('Hertz') ylabel('Magnitude') figure(2) % Plot Phase in Degrees plot(f,phase(h)*180/pi) xlabel('Hertz') ylabel('Degrees')

Resulting Plots

Decibel Scale ¾^

A decibel is a logarithmic measure of gain (or attenuation). A powergain between the designated system input and output is denoted inDecibels (or dB) as: ¾^

Express power in terms of voltage over a load to get another version ofthe dB formula:

⎞ ⎟ ⎟ ⎠

⎛ ⎜⎜ ⎝

=

out^ in

dB

P P

G

10 log

10 (^

(^

⎞ ⎟⎟ ⎠

⎛ ⎜⎜ ⎝

⎞ ⎟⎟ ⎠

⎛ ⎜⎜ ⎝

⎞ ⎟+⎟ ⎠

⎛ ⎜⎜ ⎝

⎞ ⎟⎟ ⎠

⎛ ⎜⎜ ⎝

=

⎞⎟⎟ ⎠

⎛⎜⎜ ⎝

⎞ ⎟⎟⎠

⎛⎞ ⎜⎟⎜⎟⎝⎠

⎛ ⎜⎜⎝

⎞ ⎟=⎟⎠

⎛ ⎜⎜⎝

=

in out

out in

dB

in out

out in

in in

out

out

dB

R R

V V

G

R R

V V

R V

R

V

G

10

10

2 2

10

2 2

10

log 10

log 20

log 10

/ /

log 10

Decibel Scale ¾^

If input and output impedances are considered equal (

R in

=^

R out

) the

formula reduces to: Gain is always positive (between 0 and

). Describe the gain in dB

when the system is attenuating. Describe the gain in dB when the gainis unity.

out^ in

dB^

V V

G

10

log

Bode Plot (with Matlab) ¾^

Before building our understanding on how to manipulate a polynomialfor convenient plotting, consider using Matlab to generate the plot. ¾^

Matlab Function behaves like a subroutine in a main program. Specifyinput and output arguments for your function (subroutine). The inputand output arguments are all the main program sees from the Matlabcommand line. The help files are the first set of comments and mustprovide all user needs to know in order to use it properly. ¾^

Example: Create a Matlab function that evaluates a TF based on itspolynomial coefficients. Generate a script that calls this function toshow how it works.

Matlab Example ¾^

For a function, start the first line with the word “function”followed by the function syntax (input and outputarguments). Comments immediately following this firstline will be used as the “help” for this function and mustshow how the function is used.

function p = tfeval(ns, ds, f)

Matlab Example num_order = length(ns)-1; % Determine order of numerator den_order = length(ds)-1; % Determine order of denominator s = j2pi*f;

% Create s vector for evaluating TF

% Loop to sum up every term in numerator sumn = zeros(size(s)); % Initialize accumulation variable for k=1:num_order+

sumn = sumn + ns(k)*s.^(num_order-k+1); end % Loop to sum up every term in numerator sumd = zeros(size(s)); % Initialize accumulation variable for k=1:den_order+

sumd = sumd + ds(k)*s.^(den_order-k+1); end % Initialize output array to NaN (not a number) for cases where %^

the denominator is zeros (a pole) p = NaN*ones(size(s)); % Fill output vector with actual values where denominator is not 0 notzero = find(sumd ~= 0); % Get indices of vector where denominator is not zero p(notzero) = sumn(notzero) ./ sumd(notzero);

Matlab Example ¾^

The following script will create the input variables for the function and plot theoutput. % This scripts demonstrates the TFEVAL function by evaluating %^

a transfer function at many points and plotting the result %^

on both a linear and log scale % generate 1000 points equally spaced on a Log Scale from 20 to 20kHz f = logspace(log10(20),log10(20000),1000); %^

3*s

% H(s) = -------------------------------- %^

s^2 + 1.81k*s + 900M

nu = [3 0];

% Numerator polynomial

de = [1 1.81e3 900e6]; % Denominator polynomial tf = tfeval(nu, de, f);

% Evaluate Transfer function

Matlab Example figure(3) % Plot result on a log scale semilogx(f,20log10(abs(tf))) % Plot magnitude title('Transfer Function Example - Log (dB) scale') xlabel('Hertz') ylabel('TF magnitude in dB') figure(4) semilogx(f,phase(tf)180/pi) % Plot phase title('Transfer Function Example - Log Scale') xlabel('Hertz') ylabel('TF phase (degrees)')

Plot Results ¾^

Linear Scales^0

0.^

1

1.^

2

2.5^4 x 10

x 101.8 1.6 1.4 1.2 (^1) 0.8 0.6 0.4 0.2 0

-^

Transfer Function Example - Linear

Hertz

TF magnitude

0

0.^

1

1.^

2

2.5^4 x 10

100 80 60 40 20 0 -20 -40 -60 -80 -

Transfer Function Example - Linear Scale

Hertz

TF phase (degrees)