Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
250 views7 pages

EEE - 321: Signals and Systems Lab Assignment 1

This document provides instructions for a lab assignment on signals and systems. It includes the following key points: - The assignment has two parts to be submitted on different dates. It involves both theoretical questions and MATLAB exercises. - Part 1 covers basic MATLAB vector operations and plotting functions like plot, stem, xlabel, ylabel etc. using sinusoidal signals as examples. - Part 2 generates and plots various continuous-time signals like cosine, decaying cosine, and sum-of-cosines. It also uses the sound function to generate and listen to the signals. - Effects of parameters like frequency, phase, decay factor on the generated signals and sounds are analyzed. Trigonometric identities are used to

Uploaded by

Atakan Yiğit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
250 views7 pages

EEE - 321: Signals and Systems Lab Assignment 1

This document provides instructions for a lab assignment on signals and systems. It includes the following key points: - The assignment has two parts to be submitted on different dates. It involves both theoretical questions and MATLAB exercises. - Part 1 covers basic MATLAB vector operations and plotting functions like plot, stem, xlabel, ylabel etc. using sinusoidal signals as examples. - Part 2 generates and plots various continuous-time signals like cosine, decaying cosine, and sum-of-cosines. It also uses the sound function to generate and listen to the signals. - Effects of parameters like frequency, phase, decay factor on the generated signals and sounds are analyzed. Trigonometric identities are used to

Uploaded by

Atakan Yiğit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

B ILKENT U NIVERSITY E LECTRICAL AND E LECTRONICS E NGINEERING D EPARTMENT

EEE - 321: Signals and Systems


Lab Assignment 1

For Section-I report submission is due by 10.10.2017


For Section-II report submission is due by 12.10.2017

Please carefully study this assingment before coming to the laboratory. You may begin
working on it or even complete it if you wish, but you do not have to. There will be short
quizzes both at the beginning and end of the lab session; these may contain conceptual,
analytical, and Matlab-based questions. Within one week, complete the assignment in the
form of a report and turn it in to the assistant. Some of the exercises will be performed
by hand and others by using Matlab. What you should include in your report is indicated
within the exercises.

Part 1

This part contains Matlab exercises demonstrating the vector-based programming logic
of Matlab. You are advised to study the examples provided in the pdf named lab0.pdf which
you can find at the course website under the link lab0. In this lab you will learn how signals
are defined and represented in Matlab as vectors.Try all the exercises below in Matlab, and
answer the related questions. Write down your answers in your report. You do not need to
provide any code for the exercises in this part.

• a) In Matlab command window type a=[1;-12.3; pi; sqrt(5)], then type a=[1 -12.3 pi
sqrt(5)]. What is the difference?

• b) Type a=[1;-12.3; pi; sqrt(5)]; and b=[1 -12.3 pi sqrt(5)];. What is the difference
from part a? Then type c=a*b. Why Matlab returns a matrix?

1
• c) Repeat part b by typing c=b*a. Why Matlab returns a scalar now?

• d) Type a=[1,-12.3,pi,sqrt(5)]; and b=[1 -12.3 pi sqrt(5)]; do you see any difference in
vectors a and b? Then type c=a*b. Why does Matlab returns an error now?

• e) Type a=[1 -12.3 pi sqrt(5)]; and b=[1 -12.3 pi sqrt(5)];. Then type c=a.*b. What is
the result? What is the effect of adding the dot in front of the multiplication symbol?

• f) Type a=[0:1:10]. What does such a command do? Now type b=[0:10]. Do you see
any difference between vectors a and b? Regenerate another vector a2 whose first
and last elements are 0 and 100, respectively, and contains 100 samples.

• g) Type a=[0:pi/8:2*pi]. Then type b=sin(a). Examine the resulting b. Notice that as
the input argument for the sin function, we used the vector a. This does not make
sense mathematically, because we have to insert a single real valued number to the
sin(x) function. For instance, sin( π8 ) has a meaning but sin([ π8 π4 ]) does not in the
ordinary sense. But Matlab still returns a result when we insert a into the sin function.
What does Matlab do?

• h) Type t=[0:0.01:2];, and type x=sin(2*pi*t);. Now first type plot(x) and then type
plot(t,x). What is the difference? You do not need to include the plots to the report,
just provide your answer to this question.

• i) For the above part, type plot(t,x,‘-+‘). What do you observe? Type plot(t,x,‘+‘).
What happens?

Type help plot in the Matlab command window, and see what else you can do with the
plot command, which is one of the vital commands of Matlab. Also study the Matlab com-
mands xlabel, ylabel, title, xlim, ylim and grid. These commands are essential for pro-
ducing professional looking plots in Matlab. Make sure that you can confidently use these
commands. As a final exercise to further understand the plot command, we will graph the
function x(t ) = sin(2πt + π/6). For this part, provide your answers to the questions that are
asked below. You will also provide a graph. Again, no codes are necessary.

• j) Let t=[0 0.02 0.04 ... 0.96 0.98 1]. By now, you know that we can prepare the array
t with the single-line command t=[0:0.02:1];. How would you generate same t using
linspace command instead?

• k) Now compute x(t ) over the time grid specified by t, and denote the resulting ar-
ray with x. By now, you know that we can obtain x with the single-line command
x=sin(2*pi*t+pi/6);.

• l) Type figure;. You will see that an empty figure window will be opened. Then type
plot(t,x,’r’);. You will see that your function is plotted, where the color of the curve is
red. Then type hold on;. This command will enable you to make further plots within
the same figure window while preserving all the old plots.

2
• m) Now let t=[0 0.05 0.1 0.15 ... 0.90 0.95 1] and compute x once again. How many
time points do we take this time? Type plot(t,x,’–g’); this time. You will notice that a
dashed green curve is added to the old figure window.

• n) Continue with t=[0 0.1 ... 0.9 1]. Try to make your plot style different from what
you obtained in part l and m.

• o) Now label the x-axis as time and y-axis as Amplitude. Also introduce a title for
your figure as Sinusioidal Signal.

• p) Closely examine the figure that you obtained, perhaps zooming in or out. Which
choice of t produces the best plot for x(t )? Why?

• q) How does the plot command “fill” the space between data points?

• r) Suppose t=[1 2 3] and x=[-1 2 -1]. Roughly sketch with your hand the plot that
Matlab would generate if we issued the command plot(t,x).

• s) After closing the figure window you used during the previous items, repeat the
exercise in item n by using the stem command instead of the plot command. Do not
provide any graphs, but just answer the following question: What is the difference
between the plot command and stem command?

Part 2

Consider a general continous-time sinusoidal signal of the form:

x c (t ) = A c cos(2π f 0 t + φ). (1)


where A c is the amplitude, f 0 is the frequency, t is the time and φ is the phase.
Since the computers have a discrete nature, it is not possible to generate a continuous
cosine signal in Matlab. However, for a given frequency f 0 , it is possible to generate an ap-
proximate continuous cosine signal by choosing the time index with high resolution.For
this part you may assume A c as 1, φ = 0 and t=[0:1/8192:1], where the unit of time is as-
sumed as seconds.

• a) Take f 0 = 500 Hz. Compute x c (t ) and store it in an array named x1. Plot x1 versus
t. Turn on the speakers of your computer. Then type sound(x1). Listen to the sound.

• b) Repeat a for f 0 = 700 Hz, but do not produce any plot.

• c) Repeat a for f 0 = 900 Hz, but do not produce any plot.

What happens to the pitch of the sound as the frequency increases?

Now generate a new time vector t, for φ = 0 and f 0 = 1000Hz such that you can listen to
this tone for 5 seconds. That is, you will write the command t = [0 : ∆t : 5];, where ∆t is to be

3
computed such that at each period of the cosine signal will have 100 sample points. What
is the total number of time samples in 5 seconds for a 1000Hz tone signal?
For the new vector t, generate the approximate continuous cosine signal and name it
as x2. Listen to x2 using the soundsc command. In order to listen to the cosine signal
appropriately, you need to compute the sampling rate which will be given as an input to
the soundsc command, as well. Describe how you compute this sampling rate?

• d) For f 0 = 1000Hz, compute x2 with φ = π6 with a single Matlab command. Listen


to the sound using soundsc with the sampling frequency you found earlier. Do not
produce any plot

• e) Repeat d for φ = π2 , but do not produce any plot.

• f) Repeat d for φ = π, but do not produce any plot.

Do you recognize a difference between the sounds that you listened for different phases?
What is the effect of the phase on the sound that hear. Plot two periods of x2 for φ = 0 as if
it is a continuous signal. Clearly label the plot and put an appropriate title.

Now consider a decaying continuous cosine signal defined for the same values of t used
in previous items,

x 3 (t ) = e −at cos(2π f 0 t ). (2)


Take f 0 = 1000 and a = 5. Compute x 3 (t ) and store it in an array named x3. Write a single
line code for computing x3. In this code, make use of the element-wise multiplication facil-
ity of Matlab while computing the product of e −at and cos(2π f 0 t ). Provide this code to your
report. Make a plot of x3 versus t, and listen to x3 by the soundsc command for 5 seconds.
Compare your plot and what you hear to the results you obtained for x2. What is the effect
of adding the e −at term to the sound that you hear? Now take a = 3, and recompute x3 (do
not change t and f 0 ). Compare the sound you hear with that of the a = 5 case. Repeat for
a = 9. How does the duration of the sound that you hear change as a increases?
Next, consider the signal

x 4 (t ) = cos(2π f 1 t ) cos(2π f 0 t ), (3)


where f 1 ¿ f 0 . Take f 0 = 1000 and f 1 = 10. Again using a single line command, compute x4
(provide this code to your report) and plot and listen to it. Compare you results with that
of x2(t ). What is the effect of the low frequency cosine term cos(2π f 1 t ) on the sound you
hear? Recompute x4 for f 1 = 5 and f 1 = 15. What is the change in the sound that you hear?
By using a trigonometric identity, write x 4 (t ) as a sum of two different frequency cosine
signals, can you interpret this change in sound analyticaly?

4
Part 3

A continuous time complex sinusoid is defined as

x s (t ) = A s e j ωt , (4)
where A s is a complex valued number and determines the complex amplitude of the sinu-
soid. Euler expansion states that x s (t ) can be written as

x s (t ) = A s e j ωt = |A s |e j ∠ A s e j ωt = |A s |e j (∠ A s +ωt ) = |A s |[cos(∠ A s + ωt ) + j sin(∠ A s + ωt )]. (5)

where ω = 2π f , and f is the tone frequency in Hz.

• a) For f 1 = 500 and f 2 = 1000, generate the signals x 1 (t ) and x 2 (t ) respectively. Take
A s = 1 and choose the resolution for vector t such that continuous nature of signal
x s (t ) = x 1 (t ) + x 2 (t ) is reflected.

• b) Plot the real and imaginary parts of x s (t ) as well as its complex amplitude and
phase. The plots should be located in the same figure window, but at separate po-
sitions within the window (Hint: use the subplot command). Clearly label the plots
and put an appropriate title.

• c) By looking at the plots, can you separate two different complex sinusoids? In other
words, by looking at the plots, would you infer that the plots that you look includes
two different complex sinusoidal signals?

Part 4

The instantaneous frequency of a signal of the form

x(t ) = cos(2πφ(t )) (6)


is defined as

d φ(t )
f i ns (t ) =. (7)
dt
Show that the instantaneous frequency of the signal x c (t ) given in Eq. 1 is given as
f i ns (t ) = f 0 for all t . Next, consider a signal of the following form

x 5 (t ) = cos(2παe t ). (8)
Show that the instantaneous frequency of the signal x 5 (t ) is given as f i ns (t ) = αe t
for all t . Thus, instantaneous frequency changes exponentialy with time. What is
the frequency at t = 0? What is the frequency at some t = t 0 ? To get a feeling about
the physical implication of the exponentialy varying instantaneous frequency, let us

5
compute x 5 (t ) and listen to it. Take t=[0:1/8192:1]. Take α = 250. With these selec-
tions, what are the values between which the frequency will change? Now compute
x5 again with a single line command and provide this command in your report. Then,
listen to x5. Now, comment on the physical implication of the exponentialy changing
instantaneous frequency. Keep t the same, and repeat the experiment with α = 300
and α = 500. Comment on the changes. In these examples, we only increased the fre-
quency of the sound signal from α Hz to αe 1 Hz. Now consider the following signal:

x 6 (t ) = cos(2π(−400t 5 + 1800t )). (9)

Take t=[0:1/8192:1]. Prepare x6 with a single line command and provide your code.
Then listen to x6. How does the frequency of the signal change as time goes on? Find
the instantaneous frequency for x 6 (t ). What is the frequency at t = 0? What is the
frequency at t = 1?

Part 5

A discrete time cosine signal like any other discrete time signal is defined over integers
by its most general form, x[n] = A cos(ωn + φ), where n ∈ Z . A is the amplitude, ω is the
normalized frequency in radians and φ is the phase shift, also in radians. First consider the
following discrete time signal:

x 7 [n] = cos(0.01πn). (10)

• a) Generate a segment of x 7 (t ) in Matlab for n ∈ (0, 255). Name it as x7.

• b) Access from the memory and print x 7 [0], x 7 [21], x 7 [121] and x 7 [250].

• c) Plot x 7 (t ) in Matlab, adopting a graphic style that clearly shows the discrete nature
signal. Make sure to label the axis. Save the plot and include it in your report.

A discrete signal x[n] is said to be periodic if there exists a positive integer N that satisfies

x[n] = x[n + N ]. (11)

∀n. The smallest N that satisfies the periodicity condition is again called as the funda-
mental period. If a discrete signal is periodic with N , it is also periodic with kN , for any
positive integer valued k.

• d) Use the above definition to find whether x 7 (t ) given in Eq. 10 is periodic or not.
State its period N if it is periodic.

6
• e) Repeat item (d) for the following discrete-time sinusoids
(i)x 8 [n] = cos(2.1πn)
(ii)x 9 [n] = cos(3n)
(iii)x 10 [n] = cos(0.2πn + 0.5)
(iv)x 11 [n] = cos(1.01πn − 0.5)
(v)x 12 [n] = cos(αn 2 ) Is there any α that makes x 12 a periodic function. If yes, find the
set of α values that makes cos(αn 2 ) a periodic function.

• f) Write the most general property that ω must satisfy to make a discrete cosine peri-
odic.

• g) Compare and discuss the periodicity properties of discrete cosine signals with that
of the continuous cosine signals.

You might also like