Lecture 14
Lecture 14
• Continuous-time sinusoids
• Discrete-time sinusoids
-1
0 5 10 15 20 25 30
time in milliseconds
0 0 0
-1 -1 -1
0 5 10 15 20 25 30 0 5 10 15 20 25 30 0 5 10 15 20 25 30
time in milliseconds time in milliseconds time in milliseconds
frequency
ELEC1200 https://www.youtube.com/watch?v=iAi3vi2j7N0 3
ELEC1200: A System View of
Communications: from Signals to Packets
Lecture 14
• Motivation
– Music as a combination of sounds at different frequencies
• Continuous-time sinusoids
• Discrete-time sinusoids
ELEC1200 4
Sinusoidal Waves
0 0
-1 -1
-2 -2
𝑇𝑇/2 𝑇𝑇 3𝑇𝑇/2 2𝑇𝑇 𝑇𝑇/2 𝑇𝑇 3𝑇𝑇/2 2𝑇𝑇
t (sec) t (sec)
Parameters:
𝒇𝒇 = Frequency in hertz (cycles per second)
𝑻𝑻 = Period (in seconds) = 𝒇𝒇−𝟏𝟏
ELEC1200 5
Phase
cos 2𝜋𝜋𝑓𝑓𝑡𝑡 + 𝜙𝜙
• It is useful to add a phase parameter, 1
𝜙𝜙 = −𝜋𝜋/2
𝜙𝜙 ∈ 0,2𝜋𝜋 or −𝜋𝜋, 𝜋𝜋 , 0
-1
which shifts the cosine wave back and forth in 0 𝑇𝑇�
4
𝑇𝑇�
2
3𝑇𝑇�
4 𝑇𝑇
time. 1
𝜙𝜙 = −𝜋𝜋/4
0
-1
• Recall that cos(𝑡𝑡) reaches its maximum value at 0 𝑡𝑡0 𝑇𝑇� 𝑇𝑇� 3𝑇𝑇� 𝑇𝑇
4 2 4
0, i.e., cos 0 = 1 . 1
0 𝜙𝜙 = 0
• Thus, cos( 2𝜋𝜋𝑓𝑓𝑡𝑡 + 𝜙𝜙) reaches its maximum value -1
0 𝑇𝑇� 𝑇𝑇� 3𝑇𝑇� 𝑇𝑇
4 2 4
at 𝑡𝑡0 , where 1
2𝜋𝜋𝜋𝜋𝑡𝑡0 + 𝜙𝜙 = 0 0
𝜙𝜙 = 𝜋𝜋/4
-1
0 𝑇𝑇� 𝑇𝑇� 3𝑇𝑇�
𝜙𝜙 4 2 4 𝑇𝑇
𝑡𝑡0 = − 1
2𝜋𝜋𝜋𝜋
0
𝜙𝜙 = 𝜋𝜋/2
-1
0 𝑇𝑇�
4
𝑇𝑇�
2
3𝑇𝑇�
4 𝑇𝑇
t (sec)
ELEC1200 6
Sine is a shifted cosine
cos 2𝜋𝜋𝑓𝑓𝑡𝑡 + 𝜙𝜙
• Recall that 1
𝜙𝜙 = −𝜋𝜋/2
cos(𝐴𝐴 + 𝐵𝐵) = cos(𝐴𝐴)cos(𝐵𝐵) – sin(𝐴𝐴)sin(𝐵𝐵). 0
-1
• Thus, 0 𝑇𝑇�
4
𝑇𝑇�
2
3𝑇𝑇�
4 𝑇𝑇
= cos 2𝜋𝜋𝜋𝜋𝑡𝑡 cos 𝜙𝜙 − sin 2𝜋𝜋𝑓𝑓𝑡𝑡 sin 𝜙𝜙 1
𝜙𝜙 = −𝜋𝜋/4
0
-1
• Since cos −𝜋𝜋2 = 0 and sin −𝝅𝝅𝟐𝟐 = −1, 0 𝑡𝑡0 𝑇𝑇�
4
𝑇𝑇�
2
3𝑇𝑇�
4 𝑇𝑇
1
𝜋𝜋
cos 2π𝑓𝑓t − = cos 2π𝑓𝑓𝑡𝑡 � 0 − sin 2π𝑓𝑓𝑡𝑡 � −1 0 𝜙𝜙 = 0
2
-1
0 𝑇𝑇� 𝑇𝑇� 3𝑇𝑇� 𝑇𝑇
= sin 2π𝑓𝑓𝑡𝑡 4 2 4
1
• Thus, a sine wave is just a phase-shifted cosine. 0
𝜙𝜙 = 𝜋𝜋/4
-1
0 𝑇𝑇� 𝑇𝑇� 3𝑇𝑇� 𝑇𝑇
4 2 4
1
• Only need to work with cosines (with phase shift)! 0
𝜙𝜙 = 𝜋𝜋/2
-1
0 𝑇𝑇�
4
𝑇𝑇�
2
3𝑇𝑇�
4 𝑇𝑇
t (sec)
ELEC1200 7
General Form
• Any sinusoidal signal can be expressed as 𝐴𝐴 cos( 2𝜋𝜋𝑓𝑓𝑡𝑡 + 𝜙𝜙)
1 𝐴𝐴 = amplitude
𝐴𝐴 𝑓𝑓 = frequency
𝜙𝜙 = phase
0 𝑇𝑇 = period
𝑡𝑡0
𝜙𝜙
𝑡𝑡0 = −
-1
2𝜋𝜋𝜋𝜋
𝑇𝑇 = 𝑓𝑓 −1
-2
-1 -0.5 0 0.5 1
ELEC1200 8
ELEC1200: A System View of
Communications: from Signals to Packets
Lecture 14
• Motivation
– Music as a combination of sounds at different frequencies
• Continuous-time sinusoids
• Discrete-time sinusoids
ELEC1200 9
Continuous and Discrete Signals
10
0
0 5 10 15 20
-5
-10
-15
x[n]
ELEC1200 10
Discrete Time Cosines
• In this course, we consider only discrete time cosine waveforms with a finite
number of samples, N (typically a power of 2), indexed by 𝒏𝒏 ∈ 𝟎𝟎, 𝟏𝟏, 𝟐𝟐, … , 𝑵𝑵 − 𝟏𝟏 .
• A discrete time cosine has the form
𝑘𝑘 𝑁𝑁
𝑥𝑥 𝑛𝑛 = cos 2𝜋𝜋 𝑛𝑛 + 𝜙𝜙 where 𝑘𝑘 ∈ 0,1, … , and 𝜙𝜙 ∈ [0,2𝜋𝜋) or [−𝜋𝜋, 𝜋𝜋)
𝑁𝑁 2
𝑁𝑁 = 32
1
0.5
𝑘𝑘 = 4
0 𝜙𝜙 = 0
-0.5
-1
0 5 10 15 20 25 30 n
-1
n
𝑁𝑁 = 64 0 10 20 30 40 50 60
k=2
1
𝜙𝜙 = 0
𝑁𝑁
0
period = 32
period =
𝑘𝑘
-1
n
0 10 20 30 40 50 60
k=4
0
-1
n period = 16
0 10 20 30 40 50 60
-1
n k=8
period= 8
0 10 20 30 40 50 60
ELEC1200 12
Relationship between Discrete and Continuous Time
𝑘𝑘
• Suppose that 𝑥𝑥 𝑛𝑛 = cos 2𝜋𝜋 𝑛𝑛 is obtained by sampling a continuous time cosine at
𝑁𝑁
1
a sampling frequency of 𝐹𝐹𝑠𝑠 (sample period 𝑇𝑇𝑠𝑠 = ).
𝐹𝐹𝑠𝑠
𝑡𝑡
• Since the 𝑛𝑛th sample is at time 𝑡𝑡 = 𝑛𝑛 ⋅ 𝑇𝑇𝑠𝑠 (𝑛𝑛 = ). Thus, the continuous time
𝑇𝑇𝑠𝑠
1
waveform is 𝑇𝑇𝑠𝑠 =
𝐹𝐹𝑠𝑠
𝑘𝑘 𝑘𝑘 𝑡𝑡 𝑘𝑘 𝑘𝑘
𝑥𝑥𝑐𝑐 𝑡𝑡 = cos 2𝜋𝜋 𝑛𝑛 � = cos 2𝜋𝜋 = cos 2𝜋𝜋 𝐹𝐹 𝑡𝑡 = cos 2𝜋𝜋𝑓𝑓𝑡𝑡 where 𝑓𝑓 = 𝐹𝐹
𝑁𝑁 𝑡𝑡
𝑛𝑛=𝑇𝑇 𝑁𝑁 𝑇𝑇𝑠𝑠 𝑁𝑁 𝑠𝑠 𝑁𝑁 𝑠𝑠
𝑠𝑠
𝑁𝑁 = 32
1
4
= 64 kHz
-0.5
32
= 8 kHz
-1
0 5 10 15 20 25 30
n
1
𝑇𝑇𝑠𝑠 = = 16μs
𝐹𝐹𝑠𝑠 32 32
32 samples = 32 ⋅ 𝑇𝑇𝑠𝑠 = = = 0.5ms
𝐹𝐹𝑠𝑠 64000
ELEC1200 13
ELEC1200: A System View of
Communications: from Signals to Packets
Lecture 14
• Motivation
– Music as a combination of sounds at different frequencies
• Continuous-time sinusoids
• Discrete-time sinusoids
ELEC1200 14
Sinusoidal Representation of Sampled Data
• Any sampled data waveform x(n) with N samples:
x(n)
= for n 0,1, (N − 1)
can be expressed as the sum of a N/2+1 cosine waves using the equation
ELEC1200 15
Interpretation
1 20
𝑁𝑁/2 1 + 0.8 cos( 2𝜋𝜋 𝑛𝑛) + 0.1 cos( 2𝜋𝜋 𝑛𝑛)
𝑘𝑘 256 256
2
𝑥𝑥(𝑛𝑛) = � 𝐴𝐴𝑘𝑘 cos( 2𝜋𝜋 𝑛𝑛 + 𝜙𝜙𝑘𝑘 ) Large low frequency component
𝑁𝑁 Small high frequency component
𝑘𝑘=0 𝐴𝐴0 = 1
𝐴𝐴1 = 0.8 1
𝐴𝐴20 = 0.1
• A0 controls the average level,
also called the DC offset. 0
0 50 100 150 200 250
n
• Ak controls the amplitude of
the cosine with frequency k. 1 + 0.1 cos( 2𝜋𝜋
1
𝑛𝑛) + 0.8 cos( 2𝜋𝜋
20
𝑛𝑛)
256 256
• φk controls the phase of the 2
0
0 50 100 150 200 250
n
ELEC1200 17
Amplitude Spectrum
• A plot of Ak versus frequency k
• Gives a graphical representation of which frequencies are most
important
Large low frequency component Large high frequency component
Small high frequency component Small low frequency component
2 2
𝑥𝑥(𝑛𝑛) 𝑥𝑥(𝑛𝑛)
1 1
0
0 50 100 150 200 250
𝑛𝑛 0 𝑛𝑛
0 50 100 150 200 250
1 1
𝐴𝐴𝑘𝑘 𝐴𝐴0 = 1 𝐴𝐴0 = 1
𝐴𝐴1 = 0.8
𝐴𝐴𝑘𝑘
0.5 0.5 𝐴𝐴1 = 0.1
𝐴𝐴20 = 0.1 𝐴𝐴20 = 0.8
0
0 10 20 30 40
𝑘𝑘 0
0 10 20 30 40
𝑘𝑘
ELEC1200 18
Example: Square Wave Tone
-1
n
0 50 100 150 200 250
amplitude spectrum
0.2
0.1
0 k
0 20 40 60 80 100 120
ELEC1200 20
Transforms
ELEC1200 21
Summary
• Any signal can be expressed as the sum of cosines with different
amplitudes, frequencies and phases.
ELEC1200 22
Appendix: Discrete Fourier Transform (DFT)
• The DFT takes a waveform x(n) and returns a set of N complex valued
coefficients, called Fourier coefficients.
– The Fourier coefficients are denoted by Xk for k=0,1…(N-1)
– The formula (not important for this course) is
N −1
∑
− j 2 πkn
=Xk x(n)e =
N
for k 0,1, , (N − 1)
n=0
This is the complex exponential
For more details wait until you take ELEC2100
– For this course, we use MATLAB’s “fft” function to compute the Fourier coefficients.
• From the first N/2+1 Fourier coefficients, we can compute Ak and φk for k=0,1,…,
(N/2)
N1 Xk k = 0 or N
2
Ak = 2 φk =∠Xk
N Xk otherwise
ELEC1200 23
Appendix: complex numbers
• Define j= −1
• A complex number is given by z = a+jb, where
– a is the “real” part = Re{z}
– b is the “imaginary” part = Im{z}
• Since a complex number has two parts, we can represent it
as a point on a 2D plane (the complex plane)
• By analogy with polar coordinates, we can define the
magnitude and phase.
Im z
z
= a2 + b2 z= a + jb
b
∠z =arctan(b / a)
=a z cos(∠z) z
=b z sin(∠z)
∠z
a
ELEC1200
Re z 24
Appendix: The DFT in MATLAB
• The MATLAB function “fft” implements the “Fast Fourier Transform,” a fast way
to compute the DFT.
>> Xdft = fft(x);
returns an N dimensional vector containing the DFT coefficients.
• We need to be a bit careful with MATLAB’s indexing
– The first index of x(n) in our notation is n=0, but the first index of a vector in
MATLAB starts with 1.
– Thus, if we represent a waveform x(n) for n=0,..(N-1) in a MATLAB vector x. Then,
MATLAB signal
– Similarly,
Xdft(1) = X0
ELEC1200 25