PowerPoint Slides

advertisement
Discrete Time Periodic Signals
Definition:
A discrete time signal x[n] is periodic with period N if and only if
x[ n ]  x[ n  N ]
for all n .
Meaning: a periodic signal keeps repeating itself forever!
x[n]
N
n
Example: a Sinusoid
Consider the Sinusoid:
x [ n ]  2 cos  0.2  n  0.9 

It is periodic with period N  10 since
x [ n  10 ]  2 cos 0 . 2  ( n  10 )  0 . 9 

 2 cos 0 . 2  n  0 . 9   2    x [ n ]
for all n.
General Periodic Sinusoid
Consider a Sinusoid of the form:
k


x [ n ]  A cos  2 
n
N


with k, N integers.
It is periodic with period N since
k


x [ n  N ]  A cos  2 
(n  N )   
N


k


 A cos  2 
n    k  2   x[ n ]
N


for all n.
Example of Periodic Sinusoid
Consider the sinusoid:
x [ n ]  5 cos  0 . 3 n  0 . 1

We can write it as:
3


x [ n ]  5 cos  2 
n  0 . 1 
20


It is periodic with period N  20 since
x [ n  20 ]  5 cos 0 . 3 ( n  20 )  0 . 1

 5 cos 0 . 3 n  0 . 1  3  2    x [ n ]
for all n.
Periodic Complex Exponentials
Consider a Complex Exponential of the form:
x [ n ]  Ae
 2 
j k
n
N


It is periodic with period N since
x [ n  N ]  Ae
 Ae
 2 
j k
(n N )
N


 2 
j k
n
 N 
1
e
jk 2 
 x[ n ]
for all n.
Example of a Periodic Complex Exponential
Consider the Complex Exponential:
x[ n ]  (1  2 j ) e
j 0 . 1 n
We can write it as
x [ n ]  (1  2 j ) e
1 

j  2
n
20


and it is periodic with period N = 20.
Reference Frames
Goal:
We want to write all discrete time periodic signals in terms
of a common set of “reference signals”.
It is like the problem of representing a vector
reference frame defined by
x
• an origin “0”
 
• reference vectors e1 , e 2 ,...

x

e2
Reference
Frame
0

e1
in a
Reference Frames in the Plane and in Space
For example in the plane we need two reference vectors

x

e2
Reference
Frame
0
 
e1 , e 2

e1
  
… while in space we need three reference vectors e1 , e 2 , e 3
Reference
Frame

x

e3

e2
0

e1
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:

a 2 e2



x  a 1 e1  a 2 e 2

a 1 e1
0
Where
a1
a2


projection of x along e1


projection of x along e 2
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:

a 3 e3

a 2 e2
Where
0




x  a1e1  a 2 e 2  a 3 e 3

a 1 e1


a 1 projection of x along e1

a 2 projection of x along e
2


a 3 projection of x along e
3
The “space” is a 3 dimensional space.
Example: where am I ?
x
N
E

e2
0
200 m

e1 300 m
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
x[n ]

n

















reference signals
Back to Periodic Signals
A periodic signal x[n] with period N can be expanded in terms of N
complex exponentials
ek [ n ]  e
j 2
k
N
n
k  0 ,..., N  1
,
as
N 1
x[ n ] 
a
k 0
k
ek [n ]
A Simple Example
Take the periodic signal x[n] shown below:
2
1
n
0
Notice that it is periodic with period N=2.
Then the reference signals are
e0 [ n ]  e
e1 [ n ]  e
j 2
j 2
x[ n ]  1 . 5 e 0 [ n ]  0 . 5 e1 [ n ]
n
n
n
2
We can easily verify that (try to believe!):
 1 . 5  1  0 . 5  (  1)
0
for all n.
1
2
n
1 1
n
 (  1)
n
Another Simple Example
Take another periodic signal x[n] with the same period (N=2):
1 .3
0
n
 0 .3
Then the reference signals are the same
e0 [ n ]  e
e1 [ n ]  e
We can easily verify that (again try to believe!):
x [ n ]  0 . 5 e 0 [ n ]  0 . 8 e1 [ n ]
 0 . 5  1  0 . 8  (  1)
n
n
for all n.
Same reference signals, just different coefficients
j 2
0
n
2
j 2
1
2
n
1 1
n
 (  1)
n
Orthogonal Reference Signals
Notice that, given any N, the reference signals are all orthogonal
to each other, in the sense
 0 if m  k
 e [ n ]e m [ n ]   N if m  k
n0

N 1
*
k
Since
N 1

n0
N 1
e k [ n ]e m [ n ] 
*

n0
j 2
e
mk
N
n
 j 2
  e

n0 
N 1
mk
N
n
j 2 ( m  k )

1 e
 
mk

j 2

N
1 e
by the geometric sum
… apply it to the signal representation …
N 1

n0
N 1
N 1

 *
*
x [ n ]e k [ n ]     a m e m [ n ]  e k [ n ]
n0  m 0

 

x[ n ]
N 1
 N 1 *

  a m   e k [ n ]e m [ n ]   Na k
m 0
 n0

and we can compute the coefficients. Call X [ k ]  Na k then
N 1
X [ k ]  Na k 
 x [ n ]e
n0
 j
2
N
kn
,
k  0 ,..., N  1
Discrete Fourier Series
Given a periodic signal x[n] with period N we define the
Discrete Fourier Series (DFS) as
N 1
X [k ] 
 x [ n ]e
j
2
N
kn
,
k  0 ,..., N  1
n0
Since x[n] is periodic, we can sum over any period. The general
definition of Discrete Fourier Series (DFS) is
X [ k ]  DFS x [ n ] 
n 0  N 1

n  n0
for any n
0
j
x [ n ]e
2
N
kn
,
k  0 ,..., N  1
Inverse Discrete Fourier Series
The inverse operation is called Inverse Discrete Fourier Series
(IDFS), defined as
x [ n ]  IDFS
 X [ k ] 
1
N
N 1

k 0
j
X [ k ]e
2
N
kn
Revisit the Simple Example
Recall the periodic signal x[n] shown below, with period N=2:
2
1
n
0
1
X [k ] 

 j
x [ n ]e
2
2
nk
 x [ 0 ]  x [1](  1)  1  2  (  1) , k  0 ,1
k
k
n0
Then
X [ 0 ]  3,
X [1]   1
Therefore we can write the sequence as
x [ n ]  IDFS
1
 X [ k ] 
1

2
k 0
 1 . 5  0 . 5  (  1)
n
j
X [ k ]e
2
2
kn
Example of Discrete Fourier Series
Consider this periodic signal
x[n ]
1
10
0
n
The period is N=10. We compute the Discrete Fourier Series
9
X [k ] 
 x [ n ]e
n0
 j
2
10
kn
4

e
n0
 j
2
10
kn
2
 j
5k

10
1  e

2

 j
k
10
 1 e
 5
if k  1, 2, ..., 9
if k  0
… now plot the values …
| X [k ] |
magnitude
5
0
0
 X [k ]
2
4
6
8
10
k
8
10
k
phase (rad)
2
0
-2
0
2
4
6
Example of DFS
Compute the DFS of the periodic signal
x [ n ]  2 cos( 0 . 5 n )
Compute a few values of the sequence
x [ 0 ]  2 , x [1]  0 , x [ 2 ]  2 , x [ 3 ]  0 ,...
and we see the period is N=2. Then
1
X [k ] 

j
x [ n ]e
2
2
kn
 x [ 0 ]  x [1]  (  1)
n0
which yields
X [ 0 ]  X [1]  2
k
Signals of Finite Length
All signals we collect in experiments have finite length
x[ n ]  x ( nT s )
x (t )
Fs 
1
Ts
T MAX
N  TM AX  FS
Example: we have 30ms of data sampled at 20kHz (ie 20,000
samples/sec). Then we have
N  30  10
3
 20  10   600
3
data points
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
0
N 1
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):
X [ k ]  D F T  x [ n ] 
N 1
 x [ n ]e
 j
2
kn
N
k  0, ..., N  1
,
n0
And its inverse
x [ n ]  ID F T  X [ k ] 
1
N
N 1

n0
j
X [ k ]e
2
N
kn
,
n  0, ..., N  1
Signals of Finite Length
All signals we collect in experiments have finite length in time
x[ n ]  x ( nT s )
x (t )
Fs 
1
Ts
T MAX
N  TM AX  FS
Example: we have 30ms of data sampled at 20kHz (ie 20,000
samples/sec). Then we have
N  30  10
3
 20  10   600
3
data points
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
0
N 1
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):
X [ k ]  D F T  x [ n ] 
N 1
 x [ n ]e
 j
2
kn
N
k  0, ..., N  1
,
n0
and its inverse
x [ n ]  ID F T  X [ k ] 
1
N
N 1

n0
j
X [ k ]e
2
N
kn
,
n  0, ..., N  1
Example of Discrete Fourier Transform
Consider this signal
x[n ]
1
9
0
n
The length is N=10. We compute the Discrete Fourier Transform
9
X [k ] 
 x [ n ]e
n0
 j
2
10
kn
4

e
n0
 j
2
10
kn
2
 j
5k

10
1  e

2

 j
k
10
 1 e
 5
if k  1, 2, ..., 9
if k  0
… now plot the values …
| X [k ] |
magnitude
5
0
0
 X [k ]
2
4
6
8
10
k
8
10
k
phase (rad)
2
0
-2
0
2
4
6
DFT of a Complex Exponential
Consider a complex exponential of frequency
x[ n ]  Ae
j 0 n
,
 0 rad.
   n  
We take a finite data length
x[ n ]  Ae
j 0 n
,
0  n  N 1
… and its DFT
X [ k ]  DFT x [ n ] 
N 1
 x [ n ]e
j
2
N
kn
, k  0 ,..., N  1
n0
How does it look like?
Recall Magnitude, Frequency and Phase
Recall the following:
1. We assume the frequency to be in the interval
   0   
2. We represented it in terms of magnitude and phase:
magnitude
0

phase

|A|

 ( rad )
 A
0

 ( rad )
Compute the DFT…
X [ k ]  D F T  x [ n ] 
N 1
 x [ n ]e
 j
2
kn
N
n0
N 1


Ae
j 0 n
 j
e
2
kn
N
n0
N 1

 Ae
 2
 j k
0
N

n0
Notice that it has a general form:
 2

X [k ]  A  W N  k
 0 
 N

where (use the geometric series)
N 1
W N ( ) 
e
n0
 j n

1 e
 j N
1 e
 j

n

,
k  0, ..., N  1
See its general form:
N 1
W N ( ) 
e
n0
 j n
e
 j  ( N  1) / 2
N 
sin 

2


 
sin  
 2 
… since:
N 1
W N ( ) 

e
 j n
n0

e
 j N / 2
e
e
 j / 2

1 e
 j N
1 e
 j
j N / 2
e
 j N / 2
j / 2
e
 j / 2
e
e
e
 j N / 2
 j / 2
 e  j N / 2   e j N / 2  e  j N / 2 
 j ( N  1) / 2
   j / 2  

e

j / 2
 j / 2
e
e

e



N 
sin 

2


 
sin  
 2 
… and plot the magnitude
W N ( )
12
N
10
8
6
4
2
0
-3

-2
-1
0

1
2
2
N
N
2
3


Example
Consider the sequence
x[ n ]  e
In this case
j 0.3  n
, n  0, ..., 31
 0  0 . 3 , N  32
Then its DFT becomes
X [ k ]  W 32    0.3
   k 2
32
Let’s plot its magnitude:
, k  0, ..., 31
... first plot this …
W 32   0 . 3

40
30
N  32
20
10
0
0
1
 0  0 . 3
2
3
4
5
6
2

… and then see the plot of its DFT
X [ k ]  W N    0.3
   k 2
,
k  0, ..., N  1
N
35
30
25
20
15
10
5
0
0
5
10
The max corresponds to frequency
15
20
25
30
  5  2  / 32  0 . 312   0 . 3
k
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
x[ n ]  e
In this case
j 0.3  n
, n  0, ..., 255
 0  0.3 , N  256
>> n=0:255;
>>x=exp(j*0.3*pi*n);
>> X=fft(x);
>> plot(abs(X))
See the plot …
… and its magnitude plot
| X [k ] |
200
150
100
50
0
0
50
100
150
200
250
300
k
What does it mean?
A peak at index k 0 means that you have a frequency
0
| X [k ] |
k 0  2 / N

200
150
100
50
0
0
50
k 0  38
100
150
200
250
300
k
The max corresponds to frequency
  3 8  2  / 2 5 6  0 .2 9 6 9   0 .3
Example
You take the FFT of a signal and you get this magnitude:
| X [k ] |
1200
1000
800
600
400
200
0
0
50
k 1  27
100
k 2  81
There are two peaks corresponding
to two frequencies:
150
 1  k1
2  k2
200
2
 27
N
2
N
250
2
 0 . 2109 
256
 81
2
256
 0 . 6328 
300
k
DFT of a Sinusoid
Consider a sinusoid with frequency
0
rad.
x[ n ]  A cos( 0 n   ),    n  
We take a finite data length
x[ n ]  A cos( 0 n   ),
0  n  N 1
… and its DFT
X [ k ]  DFT x [ n ] 
N 1
 x [ n ]e
j
2
N
kn
, k  0 ,..., N  1
n0
How does it look like?
Sinusoid = sum of two exponentials
Recall that a sinusoid is the sum of two complex
exponentials
x[ n ] 
A
e
2
magnitude

e
j 0 n

A
A/2
 0
0
 0

e
 j
e
 j 0 n
2
A/2
phase

j

 ( rad )

0

 ( rad )
Use of positive frequencies
Then the DFT of a sinusoid has two components
 A j j  0 n 
 A  j  j  0 n 
X [k ]  D FT  e e
  DFT  e e

2

2

… but we have seen that the frequencies we compute
are positive. Therefore we replace the last exponential
as follows:
 A j j  0 n 
 A  j j ( 2    0 ) n 
X [k ]  D FT  e e
  DFT  e e

2

2

Represent a sinusoid with positive freq.
Then the DFT of a sinusoid has two components
 A j j  0 n 
 A  j j ( 2    0 ) n 
X [k ]  D FT  e e
  DFT  e e

2

2

magnitude
A/2
0
phase
A/2


0
2   0
2
 ( rad )
2   0


2
 ( rad )
Example
Consider the sequence
x [ n ]  2 cos(0.3 n ), n  0, ..., 31
In this case
 0  0 . 3 , N  32
Then its DFT becomes
X [ k ]  W 32    0.3   W 32    1.7 
   k 2
32
2   0 . 3
Let’s plot its magnitude:
, k  0, ..., 31
... first plot this …
1
2
W 32    0.3   W 32    1.7 

20
N / 2  32 / 2
N / 2  32 / 2
15
10
5
0
0

1
 0  0 . 3
2
3
4
5
 0  1.7 
6
2
… and then see the plot of its DFT
X [k ] 
1
2
W 32    0.3   W 32    1.7 

 k
2
,
k  0, ..., N  1
N
20
15
This is NOT a frequency
10
5
0
0
5
10
15
20
The first max corresponds to frequency 
25
30
 5  2  / 32  0 . 3
35
k
Symmetry
If the signal x[n ]
is real, then its DFT has a symmetry:
X [k ]  X [ N  k ]
In other words:
*
| X [ k ] | | X [ N  k ] |
 X [ k ]   X [ N  k ]
Then the second half of the spectrum is redundant (it does not
contain new information)
Back to the Example:
20
15
10
5
0
0
5
10
15
20
25
30
35
If the signal is real we just need the first half of the spectrum,
since the second half is redundant.
Plot half the spectrum
20
15
10
5
0
0
5
10
If the signal is real we just need the first half of the spectrum,
since the second half is redundant.
15
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
x [ n ]  cos(0.3 n ), n  0, ..., 255
In this case
 0  0.3 , N  256
>> n=0:255;
>>x=cos(0.3*pi*n);
>> X=fft(x);
>> plot(abs(X))
See the plot …
… and its magnitude plot
| X [k ] |
100
80
60
40
20
0
0
50
100
k 0  38
The first max corresponds to frequency
150
200
250
N  k 0  218
k
 0  38  2 / 256  0.3
Example
You take the FFT of a signal and you get this magnitude:
| X [k ] |
150
100
50
0
0
50
100
k 1  27 k 2  81
There are two peaks corresponding
to two frequencies:
150
 1  k1
2  k2
200
2
 27
N
2
N
250
2
 0 . 2109 
256
 81
2
256
 0 . 6328 
300
k
Download