Discrete Time Periodic Signals
A discrete time signal x[n] is periodic with period N if and only if
][][ Nnxnx for all n .
Definition:
N
][nx
n
Meaning: a periodic signal keeps repeating itself forever!
Example: a Sinusoid
[ ] 2cos 0.2 0.9x n n
Consider the Sinusoid:
It is periodic with period since 10N
][29.02.0cos2
9.0)10(2.0cos2]10[
nxn
nnx
for all n.
General Periodic Sinusoid
n
N
kAnx 2cos][
Consider a Sinusoid of the form:
It is periodic with period N since
][22cos
)(2cos][
nxknN
kA
NnN
kANnx
for all n.
with k, N integers.
1.03.0cos5][ nnx
Consider the sinusoid:
It is periodic with period since 20N
][231.03.0cos5
1.0)20(3.0cos5]20[
nxn
nnx
for all n.
We can write it as:
1.0
20
32cos5][ nnx
Example of Periodic Sinusoid
nN
kj
Aenx
2
][
Consider a Complex Exponential of the form:
for all n.
It is periodic with period N since
Periodic Complex Exponentials
][
][
22
)(2
nxeAe
AeNnx
jkn
Nkj
NnN
kj
1
njejnx 1.0)21(][
Consider the Complex Exponential:
We can write it as
Example of a Periodic Complex Exponential
nj
ejnx
20
12
)21(][
and it is periodic with period N = 20.
Goal:
We want to write all discrete time periodic signals in terms of a common set of “reference signals”.
Reference Frames
It is like the problem of representing a vector in a reference frame defined by
• an origin “0”
• reference vectors
x
,..., 21 ee
x
01e
2e
Reference Frame
Reference Frames in the Plane and in Space
For example in the plane we need two reference vectors
x
01e
2e
21,ee
Reference Frame
… while in space we need three reference vectors 321 ,, eee
0
1e
2e
Reference Frame
x
3e
A Reference Frame in the Plane
If the reference vectors have unit length and they are perpendicular (orthogonal) to each other, then it is very simple:
2211 eaeax
0
11ea
22ea
Where projection of along
projection of along
1a
2a 2e1e
x
x
The plane is a 2 dimensional space.
A Reference Frame in the Space
If the reference vectors have unit length and they are perpendicular (orthogonal) to each other, then it is very simple:
332211 eaeaeax
0
11ea
22ea
Where projection of along
projection of along
projection of along
1a
2a 2e1e
x
x
The “space” is a 3 dimensional space.
3a x
3e
33ea
Example: where am I ?
N
E0
1e
2e
x
m300
m200
Point “x” is 300m East and 200m North of point “0”.
Reference Frames for Signals
We want to expand a generic signal into the sum of reference signals.
The reference signals can be, for example, sinusoids or complex exponentials
n
][nx
reference signals
Back to Periodic Signals
A periodic signal x[n] with period N can be expanded in terms of N complex exponentials
1,...,0 ,][2
Nkenen
N
kj
k
as
1
0
][][N
kkk neanx
A Simple Example
Take the periodic signal x[n] shown below:
n0
1
2
Notice that it is periodic with period N=2.
Then the reference signals are
nnj
nnj
ene
ene
)1(][
11][
2
12
1
2
02
0
We can easily verify that (try to believe!):
nn
nenenx
)1(5.015.1
][5.0][5.1][ 10
for all n.
Another Simple Example
Take another periodic signal x[n] with the same period (N=2):
n0
3.0
3.1
Then the reference signals are the same0
22
0
12
21
[ ] 1 1
[ ] ( 1)
j n n
j n n
e n e
e n e
We can easily verify that (again try to believe!):
nn
nenenx
)1(8.015.0
][8.0][5.0][ 10
for all n.
Same reference signals, just different coefficients
Orthogonal Reference Signals
Notice that, given any N, the reference signals are all orthogonal to each other, in the sense
kmN
kmnene
N
nmk if
if 0][][
1
0
*
1
0 2
)(221
0
21
0
*
1
1][][
N
n N
kmj
kmjn
N
kmjN
n
nN
kmjN
nmk
e
eeenene
Since
by the geometric sum
… apply it to the signal representation …
k
N
m
N
nmkm
N
nk
nx
N
mmm
N
nk
Nanenea
neneanenx
1
0
1
0
*
1
0
*
][
1
0
1
0
*
][][
][][][][
and we can compute the coefficients. Call then kNakX ][
1,...,0 ,][][1
0
2
NkenxNakX
N
n
knNj
k
Discrete Fourier Series
1,...,0 ,][][1
0
2
NkenxkX
N
n
knNj
Given a periodic signal x[n] with period N we define the
Discrete Fourier Series (DFS) as
Since x[n] is periodic, we can sum over any period. The general definition of Discrete Fourier Series (DFS) is
1,...,0 ,][][][1 20
0
NkenxnxDFSkX
Nn
nn
knNj
for any0n
Inverse Discrete Fourier Series
1
0
2
][1
][][N
k
knNjekX
NkXIDFSnx
The inverse operation is called Inverse Discrete Fourier Series (IDFS), defined as
Revisit the Simple Example
Recall the periodic signal x[n] shown below, with period N=2:
n0
1
2
1,0,)1(21)1](1[]0[][][1
0
2
2
kxxenxkX kk
n
nkj
Then 1]1[,3]0[ XX
Therefore we can write the sequence as
n
k
knjekXkXIDFSnx
)1(5.05.1
][2
1][][
1
0
2
2
Example of Discrete Fourier Series
Consider this periodic signal
The period is N=10. We compute the Discrete Fourier Series
25
102 29 4
210 10
100 0
1 if 1, 2,...,9
[ ] [ ]15 if 0
j k
j kn j kn
j k
n n
ek
X k x n e ee
k
][nx
n010
1
… now plot the values …
0 2 4 6 8 100
5magnitude
0 2 4 6 8 10-2
0
2phase (rad)
k
k
|][| kX
][kX
Example of DFS
Compute the DFS of the periodic signal
)5.0cos(2][ nnx
Compute a few values of the sequence
,...0]3[,2]2[,0]1[,2]0[ xxxx
and we see the period is N=2. Then
k
n
knjxxenxkX )1(]1[]0[][][
1
0
2
2
which yields
2]1[]0[ XX
Signals of Finite Length
All signals we collect in experiments have finite length
)(tx )(][ snTxnx
ss TF
1
MAXTMAX SN T F
Example: we have 30ms of data sampled at 20kHz (ie 20,000 samples/sec). Then we have
points data 60010201030 33 N
Series Expansion of Finite Data
We want to determine a series expansion of a data set of length N.
Very easy: just look at the data as one period of a periodic sequence with period N and use the DFS:
n
1N0
Discrete Fourier Transform (DFT)
Given a finite interval of a data set of length N, we define the Discrete Fourier Transform (DFT) with the same expression as the Discrete Fourier Series (DFS):
21
0
[ ] [ ] [ ] , 0,..., 1N j kn
N
n
X k DFT x n x n e k N
And its inverse
21
0
1[ ] [ ] [ ] , 0,..., 1
N j knN
n
x n IDFT X k X k e n NN
Signals of Finite Length
All signals we collect in experiments have finite length in time
)(tx )(][ snTxnx
ss TF
1
MAXTMAX SN T F
Example: we have 30ms of data sampled at 20kHz (ie 20,000 samples/sec). Then we have
points data 60010201030 33 N
Series Expansion of Finite Data
We want to determine a series expansion of a data set of length N.
Very easy: just look at the data as one period of a periodic sequence with period N and use the DFS:
n
1N0
Discrete Fourier Transform (DFT)
Given a finite of a data set of length N we define the Discrete Fourier Transform (DFT) with the same expression as the Discrete Fourier Series (DFS):
21
0
[ ] [ ] [ ] , 0,..., 1N j kn
N
n
X k DFT x n x n e k N
and its inverse
21
0
1[ ] [ ] [ ] , 0,..., 1
N j knN
n
x n IDFT X k X k e n NN
Example of Discrete Fourier Transform
Consider this signal
The length is N=10. We compute the Discrete Fourier Transform
25
102 29 4
210 10
100 0
1 if 1, 2,...,9
[ ] [ ]15 if 0
j k
j kn j kn
j k
n n
ek
X k x n e ee
k
][nx
n0
9
1
… now plot the values …
0 2 4 6 8 100
5magnitude
0 2 4 6 8 10-2
0
2phase (rad)
k
k
|][| kX
][kX
DFT of a Complex Exponential
Consider a complex exponential of frequency rad. 0
,][ 0njAenx n
We take a finite data length
,][ 0njAenx 0 1n N
… and its DFT
1,...,0,][][][1
0
2
NkenxnxDFTkX
N
n
knNj
How does it look like?
Recall Magnitude, Frequency and Phase
0
2. We represented it in terms of magnitude and phase:
( )rad0
0
magnitude
phase
|| A
A
Recall the following:
1. We assume the frequency to be in the interval
( )rad
Compute the DFT…
00
21
0
221 1
0 0
[ ] [ ] [ ]
, 0,..., 1
N j knN
n
N N j k nj knj n NN
n n
X k DFT x n x n e
Ae e Ae k N
Notice that it has a general form:
0
2[ ] NX k A W k
N
1
0
1( )
1
j NNj n
N jn
eW e
e
where (use the geometric series)
See its general form:
1( 1)/2
0
sin2
( )sin
2
Nj n j N
Nn
N
W e e
… since:
1
0
/2 /2 /2 /2
/2 /2 /2 /2
/2 /2 /2( 1)/2
/2 /2 /2
1( )
1
sin2
sin
2
j NNj n
N jn
j N j N j N j N
j j j j
j N j N j Nj N
j j j
eW e
e
e e e e
e e e eN
e e ee
e e e
… and plot the magnitude
-3 -2 -1 0 1 2 30
2
4
6
8
10
12
( )NW
N
2
N
2
N
Example
Consider the sequence
0.3[ ] , 0,...,31j nx n e n
In this case 32,3.00 NThen its DFT becomes
23232
[ ] 0.3 , 0,...,31k
X k W k
Let’s plot its magnitude:
... first plot this …
0 1 2 3 4 5 60
10
20
30
40
3.032 W
2
32N
3.00
… and then see the plot of its DFT
0 5 10 15 20 25 300
5
10
15
20
25
30
35
2[ ] 0.3 , 0,..., 1N kN
X k W k N
kThe max corresponds to frequency 3.0312.032/25
Same Example in Matlab
Generate the data:
>> n=0:31;
>>x=exp(j*0.3*pi*n);
Compute the DFT (use the “Fast” Fourier Transform, FFT):
>> X=fft(x);
Plot its magnitude:
>> plot(abs(X))
… and obtain the plot we saw in the previous slide.
Same Example in Matlab
Generate the data:
>> n=0:31;
>>x=exp(j*0.3*pi*n);
Compute the DFT (use the “Fast” Fourier Transform, FFT):
>> X=fft(x);
Plot its magnitude:
>> plot(abs(X))
… and obtain the plot we saw in the previous slide.
Same Example (more data points)
Consider the sequence
0.3[ ] , 0,..., 255j nx n e n
In this case 0 0.3 , 256N >> n=0:255;
>>x=exp(j*0.3*pi*n);
>> X=fft(x);
>> plot(abs(X))
See the plot …
… and its magnitude plot
0 50 100 150 200 250 3000
50
100
150
200
k
| [ ] |X k
What does it mean?
The max corresponds to frequency
38 2 / 256 0.2969 0.3
A peak at index means that you have a frequency 0k
0 50 100 150 200 250 3000
50
100
150
200
k
| [ ] |X k
0 38k
0 0 2 /k N
Example
You take the FFT of a signal and you get this magnitude:
0 50 100 150 200 250 3000
200
400
600
800
1000
1200
|][| kX
k271 k 2 81k
There are two peaks corresponding
to two frequencies:
6328.0256
281
2
2109.0256
227
2
22
11
Nk
Nk
DFT of a Sinusoid
Consider a sinusoid with frequency rad. 0
0[ ] cos( ),x n A n n
We take a finite data length
0 1n N
… and its DFT
1,...,0,][][][1
0
2
NkenxnxDFTkX
N
n
knNj
How does it look like?
0[ ] cos( ),x n A n
Sinusoid = sum of two exponentials
Recall that a sinusoid is the sum of two complex exponentials
njjnjj eeA
eeA
nx 00
22][
( )rad0
0
magnitude
phase
/ 2A
( )rad
0
0
/ 2A
Use of positive frequencies
0 0[ ]2 2
j n j nj jA AX k DFT e e DFT e e
Then the DFT of a sinusoid has two components
… but we have seen that the frequencies we compute are positive. Therefore we replace the last exponential as follows:
0 0(2 )[ ]2 2
j n j nj jA AX k DFT e e DFT e e
Represent a sinusoid with positive freq.
Then the DFT of a sinusoid has two components
( )rad0
0
magnitude
phase
/ 2A
( )rad2
202
/ 2A
02
0 0(2 )[ ]2 2
j n j nj jA AX k DFT e e DFT e e
Example
Consider the sequence
[ ] 2cos(0.3 ), 0,...,31x n n n
In this case 32,3.00 NThen its DFT becomes
232 3232
[ ] 0.3 1.7 , 0,...,31k
X k W W k
Let’s plot its magnitude:
3.02
... first plot this …
0 1 2 3 4 5 60
5
10
15
20
32 32
10.3 1.7
2W W
/ 2 32 / 2N
3.00 0 1.7
/ 2 32 / 2N
2
… and then see the plot of its DFT
kThe first max corresponds to frequency 3.032/25
32 322
1[ ] 0.3 1.7 , 0,..., 1
2 kN
X k W W k N
0 5 10 15 20 25 30 350
5
10
15
20
This is NOT a frequency
Symmetry
If the signal is real, then its DFT has a symmetry: ][nx
*][][ kNXkX
In other words:
][][
|][||][|
kNXkX
kNXkX
Then the second half of the spectrum is redundant (it does not contain new information)
Back to the Example:
0 5 10 15 20 25 30 350
5
10
15
20
If the signal is real we just need the first half of the spectrum, since the second half is redundant.
Plot half the spectrum
If the signal is real we just need the first half of the spectrum, since the second half is redundant.
0 5 10 150
5
10
15
20
Same Example in Matlab
Generate the data:
>> n=0:31;
>>x=cos(0.3*pi*n);
Compute the DFT (use the “Fast” Fourier Transform, FFT):
>> X=fft(x);
Plot its magnitude:
>> plot(abs(X))
… and obtain the plot we saw in the previous slide.
Same Example (more data points)
Consider the sequence
[ ] cos(0.3 ), 0,..., 255x n n n
In this case 0 0.3 , 256N >> n=0:255;
>>x=cos(0.3*pi*n);
>> X=fft(x);
>> plot(abs(X))
See the plot …
… and its magnitude plot
k
| [ ] |X k
0 50 100 150 200 2500
20
40
60
80
100
0 38k 0 218N k
The first max corresponds to frequency 0 38 2 / 256 0.3
Example
You take the FFT of a signal and you get this magnitude:|][| kX
k
There are two peaks corresponding
to two frequencies:
6328.0256
281
2
2109.0256
227
2
22
11
Nk
Nk
0 50 100 150 200 250 3000
50
100
150
271 k 2 81k