DSP First, 2/e: Lecture #2 Phase & Time-Shift Delay & Attenuation

You are on page 1of 22

DSP First, 2/e

LECTURE #2
Phase & Time-Shift
Delay & Attenuation

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 1


READING ASSIGNMENTS

 This Lecture:
 Chapter 2, Sects. 2-3 to 2-5

 Appendix A: Complex Numbers

 Appendix B: MATLAB
 Next Lecture: Complex Exponentials

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 3


LECTURE OBJECTIVES
 Derive Sinusoid Formula from a plot

 Relate TIME-SHIFT to PHASE

 Signal ENVELOPE defined

 ATTENUATION of Decaying Sinusoid

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 4


SINUSOIDAL SIGNAL

A cos( t   )
 FREQUENCY
 AMPLITUDE A
 Radians/sec
 Magnitude
 or, Hertz
  ( 2 )
(cycles/sec) f

 PHASE

1 2
T 
 PERIOD
f (insec)
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 5
PLOTTING COSINE SIGNAL
from the FORMULA

5 cos(0.3 t  1.2 )
 Determine period:
T  2 /   2 / 0.3  20 / 3
 Determine a peak location by solving
( t   )  0
 Peak at t=-4 0.3 t  1.2  0
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 6
ANSWER for the PLOT

5 cos(0.3 t  1.2 )
 Use T=20/3 and the peak location at t = -4


20

3

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 7


TIME-SHIFTED SINUSOID
x(t )  5 cos(0.3 t ) One peak at t = 0

x (t  4)  5 cos(0.3 (t  4))  5 cos(0.3 (t  ( 4))

Peak shifts from t=0 to t = -4


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 8
TIME-SHIFT

 In a mathematical formula we can replace


t with t-tm
x (t  tm )  A cos( (t  tm ))
 Thus the t=0 point moves to t=tm

 Peak value of cos(w(t-tm)) is now at t=tm


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 9
PHASE  TIME-SHIFT

 Equate the formulas:

A cos( (t  tm ))  A cos( t   )
 and we obtain:   tm  
 or, 
tm  

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 10
SINUSOID from a PLOT

 Measure the period, T


 Between peaks or zero crossings
3 steps
 Compute frequency: w = 2p/T
 Measure time of a peak: tm
 Compute phase: f = -w tm
 Measure height of positive peak: A

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 11


(A, w, f) from a PLOT


T0
1
.
01

sec
1
period
100 

 
 
20 2 2
T0.
01

tm  0.00125 sec    tm  (200 )(tm )  0.25


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 12
SINE DRILL (MATLAB GUI)

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 13


PHASE is AMBIGUOUS
 The cosine signal is periodic
 Period is 2p
A cos( t    2 )  A cos( t   )
 Thus adding any multiple of 2p leaves x(t)
unchanged

if tm   , then
 (  2 ) 
tm 2      2  tm  T
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 14
PHASE is AMBIGUOUS
 The cosine signal is periodic
 Period is 2p
A cos( t    2 )  A cos( t   )
 Thus adding any multiple of 2p to the phase
leaves x(t) unchanged
 Equivalent to time-shifting by one period:
A cos( t    2 ) 
A cos( (t  2 /  )   )  A cos( (t  T )   )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 15
PLOT the SINUSOID

5 cos(0.3 t  1.2 ) = 5 cos( 0.3 t  0.8 )


 The peak location at t = 8/3 = 2.666


 20
3

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 16


Peak Locations of a
Sinusoid Function
 cos( ) attains max value at
  2n , n  0,  1,  2,  3,...
0.3 t  1.2  2n
5 cos(0.3 t  1.2 )
t m  ,10 23 ,  4, 2 23 ,


20

3 Many peaks;
One will be closest
to the origin

© 2003-2016, JH McClellan & RW


Aug 2016 Schafer 17
Time Shift and Time Delay
d At the origin/source:
td
x0 (t )  A cos(0t   0 )

The distance between origin/source and destination is d; it


takes td for the wave to travel to the destination:

At the destination: assuming no attenuation


xd (t )  A cos(0 (t  td )   0 )  A cos(0t  0td   0 )
Phase at the destination: ( 0td   0 ) mod 2
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 18
Example
xo (t )  5 cos(0.3 t  1.2 )
Peaks occur at t m  ,10 23 ,  4, 2 23 ,
Suppose this is a tonal sound that travels at 1000 ft/s.
And suppose the distance is 2000 ft, which means a time
delay of 2s. Then,
xd (t )  5 cos(0.3 (t  2)  1.2 )
 5 cos(0.3 t  0.6  1.2 )  5 cos(0.3 t  0.6 )
The wave at the destination will have peaks at
t m  ,8 23 ,  2, 4 23 ,
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 19
Attenuation
In real waves, there will always be a certain degree of
attenuation, which is the reduction of the signal amplitude
over time and/or over distance.
x (t )  A cos( t   )
In a sinusoid, A is a constant.

 (t  2) / 2
However, the amplitude can
A(t )  e
have exponential decay, e.g.,
A(t )  Ae t / 
t / 
x (t )  Ae cos( t   )
Aug 2016 © 2003-2016, JH McClellan & RW Schafer 20
MATLAB Example (I)
Generating sinusoids in MATLAB is easy:
% define how many values in a second
fs = 8000;
% define array tt for time
% time runs from -1s to +3.2s
% sampled at an interval of 1/fs
tt = -1 : 1/fs : 3.2;
xx = 2.1 * cos(2*pi*440*tt + 0.4*pi);

The array xx then contains a “sampled” signal of:

x(t )  2.1cos(880 t  0.4 )


Aug 2016 © 2003-2016, JH McClellan & RW Schafer 21
MATLAB Example (II)
Introducing attenuation with time
% fs defines how many values per second
fs = 8000;
tt = -1 : 1/fs : 3.2;
yy = exp(-abs(tt)*1.2);% exponential decay
yy = xx.*yy;
soundsc(yy,fs)

Array yy contains a signal with changing amplitude:


1.2|t |
y (t )  2.1e cos(880 t  0.4 )
Soundsc lets you hear the signal yy

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 22


Plotting the Signal
Waveform “envelope”

a short slice

Aug 2016 © 2003-2016, JH McClellan & RW Schafer 23

You might also like