Lesson 11
1 Learning Objectives
By the end of this lesson students will be able to:
- Calculate the magnitude and phase of a transfer function given a frequency
- Convert phase angle to time shift and vice versa
- Use magnitude and phase to predict the relative shape of input and output waveforms
- Convert magnitude to dB and vice versa
- Read values from a phase and magnitude plot
2 Introduction
Previously we looked at unit and impulse inputs to systems and plotted their output.
Now we want to see what happens when we use a sine wave as an input.

3 Magnitude and Phase
Consider the following RC circuit:

The transfer function is
Remember that . But since sinusoidal inputs are steady-state inputs, . So we can re-write as :
Now, we want to know how the circuit will modify an input sine wave that has a frequency of rad/s. Type in g=1/(0.001*j*10+1) to MATLAB to find out.
Notice is now equal to a complex number, which has a magnitude and a phase angle.
In MATLAB, use abs(x) to find the magnitude:
g = 1 - j*0.01
abs(g)MATLAB will print out 1 which means . This is an approximation and the answer is really 1.000049999 if you use vpa(abs(g), 10)
In MATLAB, use angle(x) to find the phase angle:
angle(g)*180/piMATLAB will print out -0.5729, which means .
3.1 What Do These Numbers Mean?
The magnitude of tells us the ratio of the output amplitude to the input amplitude. The phase angle of tells us how much the output is shifted in time relative to the input.


Calculate the time shift between the two waveforms with
For the previous example:
vpa(abs(angle(g)/10),6)And MATLAB will output 0.000999967 which means
3.2 Student Exercise 1
Calculate the phase and magnitude of the RC circuit transfer function for frequencies , 200, and 500 rad/sec.
3.3 Student Exercise 2
Use Simulink to simulate the RC circuit above for an input voltage of V. Use ode4, fixed time-step of 1e-4, and wire input and output to a single scope. Find sine wave in Source. How does the time shift compare?
3.4 Student Exercise 3
Determine the formula for the output waveform, , if the input waveform is V.
4 Phase and Magnitude Plots
We could calculate magnitude and phase for each input, but that would get tedious. It would be much more efficient if we could just see all the phases and magnitudes at once. A computer can quickly calculate each phase and magnitude and plot it—these are called phase and magnitude plots.
Before we get into that, we need to discuss a new type of unit called the decibel.
4.1 Decibels
A decibel is a logarithmic unit written dB (10 dB, 100 dB, -5 dB, and so on).
The formula for converting a magnitude to decibels is
In this formula, is the magnitude of the transfer function . Use the function abs() in MATLAB to find magnitude. The log function is a base 10 log, so you use log10() in MATLAB.
You have two options for calculating decibels in MATLAB:
mag2db(abs(g))20*log10(abs(g))
4.2 Example 1
Given:
Required: Convert this magnitude to decibels.
4.3 Student Exercise 4
Convert the following magnitudes to dB.
| Magnitude | dB | Magnitude | dB |
|---|---|---|---|
| 0.0001 | 1 | ||
| 0.001 | 10 | ||
| 0.01 | 100 | ||
| 0.1 | 1000 |
4.4 Important Observations about dB
- If the magnitude of a transfer function is < 1 for a particular , it will have a negative dB value.
- If the magnitude of a transfer function is > 1 for a particular , it will have a positive dB value.
- A magnitude of 1 will give 0 dB. But , so a value of 0 dB is the same as a magnitude of 1. In other words, in a magnitude plot, a value of 0 dB means you get out what you put in to the system.
- A factor of 10 difference in magnitude (from 10 to 100, for example) only results in an increase of 20 dB. This fact is important. In other words, every 20 dB the magnitude increases by 10x.
To convert from dB to magnitude use the following formula:
4.5 Bode Plots
Magnitude plots that use dB on the y-axis are often called Bode plots (rhymes with “Okay”). They are semi-log plots because the x-axis is logarithmic while the y-axis is not.

The easiest way to make magnitude and phase plots of a transfer function in MATLAB is to define your transfer function using tf() and then use bode(tf).

For comparison, here is the same data plotted with a linear (non-logarithmic) x-axis:

4.6 Student Exercise 5
Given: The transfer functions shown below. Generate Bode and phase plots for each.
Required: From the plots for each, estimate if and .