Problem Set 2, 6 problems (105 points)
EE 353, Sp 2020
Readings: Chapter 2, sections 3
Problem 15 (20 points)
MATLAB is an important tool that is widely used in industry to analyze dynamic systems. This problem
set contains exercises that introduces various features of MATLAB. You can access MATLAB in the EE
computer laboratory in 208 Engineering Unit B. You can also access Matlab on your own computer
through the Penn State WebApps; the link for this is https://webapps.psu.edu. Matlab is also available
to students for free installation on their own computers. See https://software.psu.edu/mathworkslicense/-8474.
When using MATLAB, you can learn about a specific MATLAB function by typing the command help
followed by the MATLAB function name. Typing the command help by itself will display a long list of
topics for which help is available.
Start MATLAB and set the Current Folder to your working directory. Select New Script under the File tab
and save the following MATLAB m-file as go.m in your directory. Execute the m-file by typing go at the
command prompt, alternatively, press F5 when the cursor is positioned in the MATLAB editor window
containing the file go.m.
% go.m is an example m file script showing some plotting commands.
% Name: "Put your name here."
% Section "Put your section number here."
% Date last modified: 2/1/20 (You should update this as well.)
close all
% Plot the sinc(x) function, where sinc(t) = sin(t) / t
t = linspace(-15,15,301); % generate a time vector
y1 = sin(t) ./ t; % compute the sinc function for the time vector.
figure(1)
clf
plot(t,y1,’-k’)
xlabel(’Time (sec)’)
ylabel(’Amplitude’)
% Now plot an exponentially weighted sinusoid
y2 = exp(-abs(t/4)) .* cos(t);
hold on
plot(t,y2,’--r’)
title(’EE 353 Problem Set 2 Example’)
xlabel(’Time (sec)’)
ylabel(’Amplitude’)
legend(’sinc(t) = sin(t)/t’, ’e^{-|t|/4} cos(t)’)
A. (2 points) Three of the lines in the m-file end with a semicolon. What is the function of the
semicolon in MATLAB?
B. (2 points) What are the dimensions of the vectors t, y1, and y2 generated by the example mfile? {Hint: Use the MATLAB command whos or size.}
C. (2 points) Explain why you must use the operator ./ and .* in calculating the signals y1 and y2?
D. (2 points) What happens if the command hold on is removed from the m-file?
E. (2 points) What do the commands figure(1) and clf accomplish? {Hint: Try replacing the
command figure(1) with figure(3).}
F. (10 points) Type help subplot at the MATLAB command line to learn about the function
subplot. Modify the given code by adding to the example m-file so that it plots the decaying
sinusoids
𝑦𝑦(𝑡𝑡) = 3𝑒𝑒
𝑥𝑥(𝑡𝑡) = 3𝑒𝑒
−3𝑡𝑡
2 sin(2𝜋𝜋𝜋𝜋)𝑢𝑢(𝑡𝑡)
−3𝑡𝑡
2
cos(2𝜋𝜋𝜋𝜋) 𝑢𝑢(𝑡𝑡)
in the upper subplot of a new figure, figure 2, and in the lower subplot of figure 2, plots y versus
x. Use a time vector that contains 400 uniformly spaced points on the range 0≤ t ≤6. For the
upper subplot, show y as a solid black curve and x as a dash-dot blue curve using a single plot
command line. Label the two curves in the upper subplot using the legend command. For the
lower subplot, use a solid magenta curve and follow the plot command with the command
axis equal. Explain in your code comments the functionality the command axis equal
provides.
To receive credit
•
•
•
•
•
•
Turn in figures 1 and 2 along with a copy of your m-file.
Include your name and section at the top of the m-file as comment lines.
Use the MATLAB command gtext to place your name and section number within each figure.
Make sure that you appropriately label the x and y axes; no credit is given for MATLAB plots
whose axes are unlabeled.
Use the legend command to distinguish multiple curves in a single plot.
Add an appropriate title to each figure.
Problem 16 (20 points)
The ability to manipulate complex numbers is important in the analysis of circuits and systems. In EE 210
you used complex numbers known as phasors to quickly determine the sinusoidal steady-state response
of an electric circuit. Please carefully read Background Section B.1 in Lathi before attempting the
following review problems. Except for the MATLAB questions, solve the equations by hand, do not use a
calculator. To receive credit for the MATLAB questions, include an m-file with your name and section
that shows the MATLAB commands used to answers parts 4 and 5.
1
A. (2 points) Without using a calculator, express the complex number 𝑗𝑗 3 in rectangular form a + jb,
where a and b are real.
B. (2 points) Without using a calculator, express the following complex number
(1 + 𝑗𝑗)�7√3 + 𝑗𝑗7�
𝑗𝑗 3 �1 + 𝑗𝑗√3�
in polar form 𝑟𝑟𝑒𝑒 𝑗𝑗𝑗𝑗 , where 𝑟𝑟 and 𝜃𝜃 (in degrees) are real numbers.
C. (6 points) Given s, u, v, and w are arbitrary complex numbers with nonzero magnitude, establish
the following results:
(a) (2 points) 𝑠𝑠 ∙ 𝑠𝑠 ∗ = |𝑠𝑠|2
(b) (2 points) 𝑠𝑠 + 𝑠𝑠 ∗ = 2𝑅𝑅𝑅𝑅{𝑠𝑠}
(c) (2 points) 𝑠𝑠 − 𝑠𝑠 ∗ = 2𝑗𝑗𝑗𝑗𝑗𝑗{𝑠𝑠}
D. (6 points) You can determine the roots of the equation
𝑥𝑥 𝑛𝑛 + 𝑎𝑎𝑛𝑛−1 𝑥𝑥 𝑛𝑛−1 + ⋯ + 𝑎𝑎1 𝑥𝑥 + 𝑎𝑎0 = 0
using the MATLAB command roots. For example, to find the roots of
𝑥𝑥 3 + 4𝑥𝑥 2 + 𝑥𝑥 − 3 = 0
at the Matlab command prompt enter
>> roots([1, 4, 1,−3])
and MATLAB will return the roots. First determine the roots of the equation
𝑥𝑥 5 + 1 = 0
by hand and sketch their location in the complex plane. Verify your results using the MATLAB
command roots.
E. (4 points) The MATLAB command conv finds the product of two polynomials. For example,
suppose that
𝑝𝑝(𝑥𝑥) = 𝑥𝑥 4 + 3𝑥𝑥 3 + 2𝑥𝑥 2 + 3𝑥𝑥 − 8
𝑞𝑞(𝑥𝑥) = 𝑥𝑥 5 + 6𝑥𝑥 2 + 𝑥𝑥 + 15
and we wish to determine the product𝑠𝑠(𝑥𝑥) = 𝑝𝑝(𝑥𝑥) ∙ 𝑞𝑞(𝑥𝑥). Use the MATLAB commands
>> p = [1, 3, 2, 3, −8];
>> q = [1, 0, 0, 6, 1, 15];
>> s = conv(p, q)
In this case
s = [1, 3, 2, 9, 11, 30, 65, -15, 37, -120]
and so
𝑠𝑠(𝑥𝑥) = 𝑥𝑥 9 + 3𝑥𝑥 8 + 2𝑥𝑥 7 + 9𝑥𝑥 6 + 11𝑥𝑥 5 + 30𝑥𝑥 4 + 65𝑥𝑥 3 − 15𝑥𝑥 2 + 37𝑥𝑥 − 120
Determine the product
(𝑥𝑥 3 + 3𝑥𝑥 + 12)(𝑥𝑥 2 + 6𝑥𝑥 + 1)(𝑥𝑥 4 + 5𝑥𝑥 2 + 2)
using the MATLAB command conv. Hint: You will need to use the command more than once.
Problem 17 (20 points)
Consider a set of three systems with input f(t) and output y(t) that are represented by the following
ODEs for t ≥ 0:
System 1: (𝐷𝐷 3 + 6𝐷𝐷 2 + 18𝐷𝐷 + 27)𝑦𝑦(𝑡𝑡) = 𝑓𝑓(𝑡𝑡)
System 2: (𝐷𝐷 3 + 4𝐷𝐷 2 + 𝐷𝐷 − 6)𝑦𝑦(𝑡𝑡) = 𝑓𝑓(𝑡𝑡)
System 3: (𝐷𝐷 3 + 3𝐷𝐷 2 + 4𝐷𝐷 + 12)𝑦𝑦(𝑡𝑡) = 𝑓𝑓(𝑡𝑡)
A. (3 points) Use the MATLAB command roots to obtain the characteristic roots for each system
and sketch these roots in the λ-plane. (This just a complex number plane where real numbers
are on the x-axis and imaginary numbers are on the y-axis.)
B. (3 points) Based on the location of the characteristic roots, state whether the system is
asymptotically stable, marginally stable, or unstable.
C. (4 points) For the asymptotically stable and unstable systems, justify your answer in part B by
stating the form of the homogeneous solution for these systems for t ≥ 0. If the system has
complex-valued characteristic roots, express the homogeneous solution in terms of real-valued
sinusoidal terms, rather than complex-valued exponentials.
D. 4. (10 points)
a. (2 points) Given 𝑓𝑓1 (𝑡𝑡) = 𝑢𝑢(𝑡𝑡), find 𝑦𝑦1 (𝑡𝑡), the zero state of system 3. Using your results
from part A, state the form of the homogeneous and particular solutions in terms of
undetermined coefficients; you don’t need to solve for these coefficients. As time
approaches infinity, will the response 𝑦𝑦1 (𝑡𝑡) remain bounded?
b. Given 𝑓𝑓2 (𝑡𝑡) = cos(2𝑡𝑡) 𝑢𝑢(𝑡𝑡), find 𝑦𝑦2 (𝑡𝑡), the zero state of system 3. Using your results
from part 1, state the form of the homogeneous and particular solutions in terms of
undetermined coefficients; you don’t need to solve for these coefficients. As time
approaches infinity, will the response 𝑦𝑦2 (𝑡𝑡) remain bounded?
c. (6 points) Verify your qualitative results in parts (a) and (b) by using MATLAB to
numerically calculate the zero-state response. As an example, consider a system with
input f(t) and output y(t) that has the ODE representation
(𝐷𝐷 2 + 30𝐷𝐷 + 200)𝑦𝑦(𝑡𝑡) = (8𝐷𝐷 + 400)𝑓𝑓(𝑡𝑡)
This system can be represented in MATLAB by the row vectors
>> Q = [1, 30, 200];P = [8, 400];
Suppose we desire to find the zero-state response of the system to two separate inputs
𝑓𝑓1 (𝑡𝑡) = 4𝑢𝑢(𝑡𝑡) and 𝑓𝑓2 (𝑡𝑡) = (4 + 2𝑒𝑒 −𝑡𝑡 )𝑢𝑢(𝑡𝑡)
over the time range 0 ≤ t ≤ 2 using a time vector of 401 points. Construct the time
vector using the command linspace
>> t = linspace(0, 2, 401);
while the input functions are generated as
>> f1 = 4 * (t >= 0));
and
>> f2 = 4 + 2 * exp(−t);
Find the zero-state responses with the command lsim as
>> y1 = lsim(P,Q, f1, t);
and
>> y2 = lsim(P,Q, f2, t);
Using this example as a guide, write an m-file that calculates and plots the zero-state
response of system 3 system to the inputs
𝑓𝑓1 (𝑡𝑡) = 4𝑢𝑢(𝑡𝑡) and 𝑓𝑓2 (𝑡𝑡) = (4 + 2𝑒𝑒 −𝑡𝑡 )𝑢𝑢(𝑡𝑡)
over the time range 0 ≤ t ≤ 100 using a time vector of 10,001 points. To receive credit:
•
•
•
•
•
•
Turn in a copy of your m-file that generates the results for parts A and D.
Include your name and section number in the m-file.
Plot the zero-state responses for part d in two separate subplots on a single page,
with the response to f1(t) in the upper subplot and the response to f2(t) in the lower
subplot.
Use the MATLAB command gtext to place your name and section number within the
figure.
Make sure that you appropriately label the x and y axes; no credit is given for
MATLAB plots whose axes are unlabeled.
Add an appropriate title to the figure, for example, Problem Set 2 Problem 17, part
D.
Problem 18 (25 points) Do problem 1.4-5, parts a, b, f, g and h, from the course text.. Hint: for parts a
and b, make sure you pay attention to the variable of integration and the impact this has on the result.
Problem 19 (10 points) Do problem 1.4-8 from the course text.
Problem 20 (10 points) Do problem 1.4-9 from the course text.
Purchase answer to see full
attachment