0% found this document useful (0 votes)
19 views25 pages

Lecture 14

Uploaded by

ETHAN ETHAN
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)
19 views25 pages

Lecture 14

Uploaded by

ETHAN ETHAN
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/ 25

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

• Decomposing signals into a sum of cosines


– Amplitude Spectrum
ELEC1200
Motivation: Music
Music is a combination of sounds with different frequencies.
In this lecture, we see that this is true of any waveform
combination
1

-1
0 5 10 15 20 25 30
time in milliseconds

frequency = 261.63Hz (C4) frequency = 329.63Hz (E4) frequency = 392.00Hz (G4)


1 1 1

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

ELEC1200 increasing frequency 2


Visualizing the frequency content of music
amplitude

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

• Decomposing signals into a sum of cosines


– Amplitude Spectrum

ELEC1200 4
Sinusoidal Waves

Cosine Wave Sine Wave


2 2
𝑥𝑥(𝑡𝑡) = cos( 2𝜋𝜋𝑓𝑓𝑡𝑡) 𝑥𝑥(𝑡𝑡) = sin( 2𝜋𝜋𝑓𝑓𝑡𝑡)
1 1

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𝜋𝜋𝑓𝑓𝑡𝑡 + 𝜙𝜙)

𝐴𝐴 cos( 2𝜋𝜋𝑓𝑓𝑡𝑡 + 𝜙𝜙)


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

• Decomposing signals into a sum of cosines


– Amplitude Spectrum

ELEC1200 9
Continuous and Discrete Signals

1. Signal: x(t)=A cos(ωt+φ)


15

10

2. Continuous time (Analog)


5

0
0 5 10 15 20
-5

-10

-15

x[n]

3. Discrete time (Digital) 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

• The variable 𝑘𝑘 is a discrete time frequency, which has units of cycles/waveform.


• Since the waveform has N samples, the period (in samples) is

𝑁𝑁 samples waveform 𝑵𝑵 samples


period = ⋅ =
waveform 𝑘𝑘 cycles 𝒌𝒌 cycle
ELEC1200 11
Discrete time cosines with varying k
k=1
𝑘𝑘 1
period = 64
𝑥𝑥 𝑛𝑛 = cos 2𝜋𝜋 𝑛𝑛 + 𝜙𝜙
𝑁𝑁 0

-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

• If 𝐹𝐹𝑠𝑠 = 64kHz, 0.5


𝑘𝑘 = 4
𝑘𝑘
𝑓𝑓 = 𝐹𝐹 𝜙𝜙 = 0
𝑁𝑁 𝑠𝑠
0

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

• Decomposing signals into a sum of cosines


– Amplitude Spectrum

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

𝑁𝑁/2 each term in the


𝑘𝑘 summation is called a
𝑥𝑥(𝑛𝑛) = � 𝐴𝐴𝑘𝑘 cos( 2𝜋𝜋 𝑛𝑛 + 𝜙𝜙𝑘𝑘 ) frequency component (tone)
𝑁𝑁
𝑘𝑘=0

• This equation is called the Fourier series expansion of x(n)


• Different waveforms are obtained by changing the values of Ak and φk
– Since for k=0, the term in the summation is 𝐴𝐴0 cos( 𝜙𝜙0 ), we usually assume 𝜙𝜙0 = 0.

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

cosine with frequency k. 𝐴𝐴0 = 1


𝐴𝐴1 = 0.1 1
𝐴𝐴20 = 0.8

0
0 50 100 150 200 250
n

Small low frequency component


(𝜙𝜙𝑘𝑘 = 0 for all 𝑘𝑘) Large high frequency component
ELEC1200 16
Amplitude, Phase, and Frequency
• Amplitude Ak
– Tells us how much of each frequency there is.
– A0 controls the average level of the signal and is sometimes called the DC
component.
• Phase φk
– Not so important, just shifts each cosine left or right.
• Frequency k
– Tells us about how quickly the signal changes
– Low frequencies (small k) indicate slow changes.
– High frequencies (large k) indicate fast changes.
• We are most interested in the amplitude and how it changes with k.
– The frequency components with the largest amplitude are the “most important.”

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

Waveform Amplitude Spectrum


1.5
1 x(n)
1
0 2
A2cos(2π64n+φ2)
0.5
-1
n 0 k
0 16 32 48 64 0 8 16 24 32
1.5 x(n)
1
1
0 2
A2cos(2π 64n+φ2)
0.5 6
-1 +A6cos(2π 64n+φ6)
n 0 k
0 16 32 48 64 0 8 16 24 32
1.5
1 x(n)
1
0 2
A2cos(2π 64n+φ2)
0.5
-1 6
+A6cos(2π 64n+φ6)
n 0 k 10
0 16 32 48 64 0 8 16 24 32 +A10cos(2π 64 n+φ10)
ELEC1200 k 19
More Complex Example
signal

-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

• The Fourier Series is only one of a set of representations


(transforms) you will study later:
– Fourier Transform
– Laplace Transform
– Z Transform
• Transforms are merely a different way of expressing the same data.
No information is lost or gained when taking a transform.
– Loose analogy: Transform ~ Translation
• We use transforms because
– It gives us a different way of viewing or understanding the signal.
– Some operations on signals are easier to understand/analyze after taking the
transform.

ELEC1200 21
Summary
• Any signal can be expressed as the sum of cosines with different
amplitudes, frequencies and phases.

• The amplitude spectrum


– Is the weightings (sizes) of the different frequency components, Ak, plotted as
a function of frequency k.
– Tells us important information about what the signal looks like.
– Frequency components with the largest amplitudes are the “most important”.

• Knowledge of both amplitude and phase spectrum is equivalent to


knowledge of the signal.

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,

x(1)= x(0), x(2)= x(1),…, x(N)= x(N-1)

MATLAB signal
– Similarly,
Xdft(1) = X0

ELEC1200 25

You might also like