George Mason University 1 Prelab 2 Analysis of a First

George Mason University
Signals and Systems I
Spring 2015
Computer Project #3
Assigned: February 18, 2015
Due Date: Laboratory Section on Week of March 16, 2015
Description
The purpose of this laboratory is reinforce your understanding of linear time-invariant
systems that are described by linear constant-coefficient differential equations. You will
learn how to use MATLAB tools for simulating the output of these systems. It is also designed to have you explore the effect of truncating an infinite finite Fourier series expansion
to a finite number of terms. You will also be looking at what happens to a periodic signal
that is filtered by an RC circuit. Note: This lab has a lot of parts, but each part is straightforward and does not require a lot of work. But get started early!
Lab Report
Your report for this lab will consist of all the analytical (i.e, pencil/paper) work,
MATLAB plots and code, and relevant explanations. Guidelines for preparing the lab report
will be presented and discussed in your first lab section. Each student must do his or her
own work on this lab. However, you may ask other students or any of the teaching staff for
advice.
1
Prelab
Before going to lab, you may wish to review Sections 2.4, 3.2, 3.3, 3.8 and 3.9 in your
textbook, Signals and Systems by Oppenheim and Willsky. Also review your notes on
how to solve linear constant coefficient differential equations. Before starting on the lab
exercises, you may find it helpful to read the help available for the MATLAB commands
lsim, impulse, tf and step. For example, you can use help lsim to get help on the lsim
command.
2
Analysis of a First-Order System
Consider the causal LTI system defined by the differential equation
dy(t)
+ 3y(t) = 2x(t)
dt
(a) Find and sketch the step response of this system, i.e., the response of the system to
the input x(t) = u(t).
(b) Find the impulse response of this system by differentiating the step response. Sketch
the impulse response.
(c) Find and sketch the output of this system when the input is x(t) = e−5t u(t).
Hint: Since you know h(t), you should be able to find the output using convolution!
3
MATLAB Simulation of a First-Order System
In this part, you will be using MATLAB to simulate the responses of the same system you
analyzed in Part 2,
dy(t)
+ 3y(t) = 2x(t)
(1)
dt
and asked to compare your simulations to your analytical results.
(a) The MATLAB command lsim can be used to simulate the output of an LTI system
that is defined by a linear constant coefficient differential equation. In this part,
you will use lsim to simulate the step response of your first-order system.To use
lsim, you must first specify the vectors a and b that define the coefficients of the
differential equation. The vectors a and b correspond to the coefficients an and bm in
the differential equation
N
X
an
n=1
M
X
dn y(t)
dm x(t)
=
bm
n
dt
dtm
m=1
Thus, for the first-order differential equation given in Eq. (1), these vectors are given
by:
>> b=[2];
>> a=[1 3];
You also need to define a time vector t and the input x. For these, use:
>> t=0:0.01:10;
>> x=ones(1,length(t);
Note that the vector x corresponds to a unit step function. Now you can use lsim to
compute the output. However, you will first need to use the tf command to define the
transfer function of the system (frequency response) and then use lsim to compute
the output. This is done as follows,
>> sys=tf(b,a);
>> y=lsim(sys,x,t);
Using lsim, plot the results you obtain for the step response, and, on the same graph,
plot the analytical result you obtained in Part 2(a). Are the plots the same?
(b) Now use lsim to generate the output of the system defined by Eq. (1) to the input
x(t) = 3u(t − 4). Note that here you will need to define a new vector x. How is this
result different from the result in part (a)? Can you explain any differences using the
properties of linearity and time-invariance?
(c) The MATLAB command step can be used to simulate the step response of a system.
After reading the help on the step function, use it to generate the step response of
your system and plot your results. Do you obtain the same answer as in part (a)?
(d) The MATLAB command impulse can be used to simulate the output of an LTI system
when the input is an impulse. After reading the help on the impulse function, use
it to generate the impulse response of the system defined in Eq. (1). How do your
results compare to the impulse response you found in Part 2(b)? Try plotting your
analytical result on the same graph as the result obtained with impulse. Are the
graphs the same?
(e) Use the lsim command to generate the response of the differential equation in Eq. (1)
when the input is e−5t u(t). Plot the result. How does this answer compare to your
analytical calculation in Part 2(c)?
(f) Find the impulse response and step response for the linear time-invariant system
described by the differential equation
d2 y(t)
dy(t)
dx(t)
+ 0.4
+ 0.2y(t) =
+ x(t)
dt2
dt
dt
using impulse and step and discus how they differ from the impulse and step responses of the system defined by Eq. (1).
4
Fourier Series
Consider the sawtooth waveform with period T0 and fundamental frequency ω0 = 2π/T0
plotted below.
v(t)
V
t
−2T0
−T0
T0
0
2T0
The complex Fourier series coefficients of this waveform are
Vn =
jV
2πn
n 6= 0
;
with V0 = V /2. Therefore, the complex Fourier series representation of v(t) is given by:
∞
X
jV jnω0 t
V
v(t) =
+
e
2 n=−∞ 2πn
(a) Find the average power in the waveform v(t),
1
P =
T0
ZT0
0
v 2 (t)dt
(b) Express the complex Fourier series for v(t) in terms of a cosine series, i.e., one that
has the form
∞
X
v(t) = A0 +
An cos(nω0 t + φn )
n=1
(c) With V = 1 and T0 = 1, synthesize the waveform
vN (t) = A0 +
N
X
An cos(nω0 t + φn )
n=1
using only N = 6 terms in the sum and make a plot of your synthesis.
(d) Make a plot of the difference between v(t) and vN (t),
e(t) = v(t) − vN (t)
and find the peak error,
emax = max |e(t)|
and the average power in the error e(t). Hint: Use Parseval’s relation for periodic
signals,
ZT0
∞
X
1
2
|x(t)| dt =
|xn |2
T0
n=−∞
0
where xn are the complex Fourier series coefficients of x(t).
(e) Repeat parts (c) and (d) using N = 26 terms in the sum. Comment on how the peak
error and the average power in the error signal change as you add more terms in the
sum.
5
Response of LTI Systems to Periodic Inputs
Consider the RC circuit shown in the following figure,
vR (t)
+
−
+
vS (t)
R
−
+
vC (t)
C
−
The differential equation relating the voltage vS (t) to the voltage across the capacitor, vC (t),
is
dvC (t)
RC
+ vC (t) = vS (t)
dt
If the voltage source is a sinusoid,
vS (t) = cos(ω0 t)
then the voltage across the capacitor is a sinusoid of the same frequency, but scaled in
amplitude and shifted in phase,
vC (t) = |H(jω)| cos(ω0 t + φh (ω))
where
H(jω) =
1
1 + RCjω
is the frequency response of the system.
(a) If vS (t) is the sawtooth waveform given in Part 4 and RC = 1, use MATLAB to
synthesize the voltage across the capacitor,
vC (t) = A0 +
N
X
An cos(nω0 t + φn )
n=1
using N = 26 terms in the sum and make a plot of your synthesis. Hint: You know
how each cosine is modified by the circuit, so you may use linearity and the cosine
synthesis of vS (t) to find vC (t).
(b) The voltage across the resistor, vR (t), is related to the voltage source by the differential
equation
dvR (t)
dvS (t)
RC
+ vR (t) = RC
dt
dt
In this case, the frequency response is
H(jω) =
RCjω
1 + RCjω
Repeat part (a) for vR (t) and discuss the differences you find in the results for parts
(a) and (b).