Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
LEARNING OBJECTIVES
Develop the notion of a discrete-time (d-t) signal and a d-t x[n] system. Define a d-t signal and its properties, ... and perform operations on these signals. -4 -3 -2 -1
x[n] x[n] -N
2
...
0 1 2 3 5
x[n-N]
x[n]
x[-n] x[2n]
a[n]
+/b[n]
y[n]
x[n]
y[n]
x[2n] x[n]
Tutorial:
b[n] or scaling by c
Solve problems related to the above. MATLAB Exercises Chap. 1, Digital Signal Processing, Sanjit K. Mitra.
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T1
Discrete-Time Signals
A discrete-time signal is an indexed sequence of real or complex numbers. Thus, it is function of an integer-valued variable, n and is x[n] = (... 2 4 3 3 2 0 2 2 5 ...) denoted by x[n]. x[n] is generally referred to as a function of time. A d-t signal is undefined for noninteger values of n. A real-valued signal x[n] will be represented graphically in the form of a lollipop plot as shown.
AFMH
x[n]
...
-4 -3 -2 -1 0 1 2 3 5
...
DSP_L1_T2
Discrete-time signals or sequences are often derived by sampling a xa(t) continuous-time signal, such as speech, with an analog-to-digital (A/D) converter. t For example, a c-t signal xa(t) that is sampled at a rate of fs=1/Ts samples A/D per second produces the sampled signal x[n], which is related to xa(t) as xa(t) follows: x[n] Sampling x[n] = xa(nTs) interval, Ts Not all d-t signals are obtained in this n manner. Eg. Daily stock market -4 -3 -2 -1 0 1 2 3 5 prices, population statistics, etc. Created: Last update: DSP_L1_T3 AFMH June 1999 July 2010
Complex Sequences
In general, a d-t signal may be complex-valued. In digital communications, complex signals arise naturally. A general complex signal x(t) may be expressed either in terms of its real and imaginary parts, z = a + jb z[n] = Re{z[n]} + j Im{z[n]} or in polar form in terms of its magnitude and phase, z[n] = |z[n]| exp[j arg{z[n]}] z = rei
Im
The magnitude may be derived as follows: |z[n]|2 = Re2{z[n]} + Im2{z[n]} The phase may be found using arg{z[n]} = tan-1[Im{z[n]}/Re{z[n]}]
b a -b
z[n]
tan-1 b/a Re
z*[n]
If z[n] is a complex sequence, the complex conjugate denoted by z*[n] is formed by changing the sign on the imaginary part of z[n]: z*[n] = Re{z[n]} - j Im{z[n]} = |z[n]| exp[-j arg{z[n]}]
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T4
1 n = 0 [ n] = 0 n 0
The delayed/shifted unit impulse/sample sequence [n-k] is defined by
-2-1 0 1 2 3
1 n = k [n k ] = 0 n k
[n-k] 1 ... -2 -1 0 1 2
AFMH Created: June 1999
k
Last update: July 2010
n
DSP_L1_T5
1 n 0 u[n] = 0 n < 0
u[n] 1 ... n
Value of u[n] at n=0 is defined and equals -2 -1 0 1 2 3 4 5 to unity (unlike c-t step function, u(t)). The shifted unit step sequence u[n-k] is defined as
u[n-k] 1 ... -2 -1 0 1 2 k
Last update: July 2010
1 n k u[n k ] = 0 n < k
n
DSP_L1_T6
AFMH
x [ n ] [ n ] = x [ 0 ] [ n ] x [ n ] [ n k ] = x [ k ] [ n k ] u[n ] =
k =
[ k ],
[ n ] = u [ n ] u [ n 1]
Any sequence x[n] can be expressed as (see DSP_L1_T24)
x[ n ] =
k =
x[ k ] [ n k ]
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T7
x[n] = A e n + j ( n + )
o o
= Ae
on
cos(o n + ) + j A e
AFMH
on
sin(o n + )
Last update: July 2010 DSP_L1_T8
x[n] = A cos(o n + )
amplitude angular frequency initial phase
For x[n] (with o=0 for complex seq) to be periodic with period N, 0 must satisfy the following condition
0 m = 2 N
m = positive integer
2 N0 = 0
1 = f 0
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T9
% Generation of a complex exp. sequence 1 x[n] = 2 exp( 12 + j )n 6 clf; c = -(1/12)+(pi/6)*i; K = 2; n = 0:40; x = K*exp(c*n); subplot(2,1,1); stem(n,real(x)); xlabel('Time index n');ylabel('Amplitude'); title('Real part'); subplot(2,1,2); stem(n,imag(x)); xlabel('Time index n');ylabel('Amplitude'); title('Imaginary part');
2e
1 12 n
cos 212n
10
15
30
1 12 n
35
40
2e
sin 212n
Amplitude
-1
10
15
20 25 Time index n
30
35
40
AFMH
DSP_L1_T10
% Generate periodic complex sequence x[n] = exp( j 10 )n % n=[0:40]; x=exp((j*pi/10)*n); subplot(2,2,1); stem(n, real(x)) % real part subplot(2,2,2); stem(n, imag(x)) % imaginary part subplot(2,2,3); stem(n, abs(x)) % magnitude subplot(2,2,4); stem(n, angle(x)*(180/pi)) % phase in degrees
Imaginary part
10
20 Magnitude
30
40
10
20
30
40
-100 -200 0
10
20
30
40
AFMH
DSP_L1_T11
120
100
80 Amplitude
60
40
20
0 0
10
15 20 Time index n
25
30
35
AFMH
DSP_L1_T12
x[ n ] = A cos( 0 n + )
If n is dimensionless, then both 0 and have units of radians.
x[n]=cos(n/6)
-6 -12 -9 -3 0 3
6 9 12 n
% Generation of a sinusoidal sequence n = 0:40; f = 0.1; phase = 0; A = 1.5; arg = 2*pi*f*n - phase; x = A*cos(arg); clf; % Clear old graph stem(n,x);% Plot the generated sequence axis([0 40 -2 2]); grid; title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis;
Ref: Program P1_4, DSP Lab using Matlab, Mitra
10
15
20 25 Time index n
30
35
40
AFMH
DSP_L1_T14
Symmetric Sequences
x[n]
A real-valued sequence x[n] is said to be even if, for all n x[n] = x[-n] whereas it is said to be odd if, for all n x[n] = -x[-n]
0 x[n]
Any signal x[n] can be decomposed into a sum of its even part xe[n], and its odd part xo[n], as n 0 follows: x[n] = xe[n] + xo[n], Example: where x[n]=(3 6 2 10 1 8 5) x[-n]=(5 8 1 10 2 6 3) xe[n] = 1/2 {x[n]+x[-n]}, xo[n] = 1/2 {x[n]-x[-n]}. xe[n]=(4 7 1.5 10 1.5 7 4) xo[n]=(-1 -1 0.5 0 0.5 1 1)
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T15
a + jb
Re
a jb
a + jb
a + jb
Re
See Example 2.5 in Mitra for conjugate -symmetric sequence Note: A sequence that is conjugate symmetric is sometimes said to be hermitian. See Example 2.5 in Mitra for conjugate -symmetric sequence
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T16
A sequence (discrete-time signal) x[n] is said to be periodic with period N if for some positive real integer N for which x[n] x[n] = x[n+N] for all n Sequence repeats itself every N samples See TP DSP_L1-T8
It follows that x[n+mN] = x[n] for all n and any integer m Sequence is also periodic with period 2N, period 3N, and all other integer multiples of N The fundamental period N0 of x[n] is the smallest positive integer for which the above equation is satisfied. If the equation is not satisfied for any integer N, x[n] is said to be aperiodic. Created: Last update:
AFMH June 1999 July 2010
-N
DSP_L1_T17
Exercises
Determine whether or not the following signals are periodic and, for each sequence that is periodic, determine the fundamental period.
(a) x[n] = cos(0.125n) (b) x[n] = Re{e jn / 12 } + Im{e jn / 18 } (c) x[n] = sin( + 0.2n) (d) x[n] = e
j
16
cos(n / 17)
AFMH
DSP_L1_T18
Solutions
2 8
= 16
DSP_L1_T19
Solutions
N=
N1 N 2 where gcd(N1, N2) means greatest common divisor of N1 and N2. gcd( N1 , N 2 )
The same is true for x[n]=x1[n]x2[n]; however, the fundamental period may be smaller
01 = / 12, 02 = / 18
N1 = 2/ = 24, N 2 = 2/ = 36 12 18 N=
( 24 )(36 ) gcd( 24,36 )
( 24 )(36 ) = 12
Created: June 1999
72
Last update: July 2010 DSP_L1_T20
AFMH
Solutions
AFMH
DSP_L1_T21
Solutions
j
16
(d) x[n] = e
cos(n / 17)
Here we have the product of two periodic signals, Therefore, the period of the sum is
01 = / 16, 02 = / 17
N1 = 2/ = 32, N 2 = 2/ = 34 16 17 N=
( 32 )(34 ) gcd(32,34 )
( 32 )(34 ) = 544 2
AFMH
DSP_L1_T22
Note: The operations below are order-dependent. Shifting If y[n]=x[n-n0], x[n] is shifted to the right by n0 samples (delay), given n0 positive Reversal Given y[n]=x[-n] (simply involves flipping the sequence x[n] w.r.t. to index n)
-8-7 -6-5-4-3-2-10 n Time scaling Given y[n]=x[Mn] or y[n]=x[n/N] where M and N are positive integers. Up-sampling by Down-sampling x[2n] x[n/2]
by a factor of 2 a factor of 2
-2-1 0 1 2 3 4 5 6
-2 -1 0 1 2 3 4 5 6 7 8 9 10 11
AFMH Created: June 1999
n
Last update: July 2010 DSP_L1_T23
Addition The sum of 2 sequences, y[n]=a[n]+b[n] is formed by the pointwise addition of the two sequences. Multiplication (or modulation) The product of 2 sequences, y[n]=a[n]b[n] is formed by the pointwise product of the two sequences.
-1 2 3 5
0 -1 5 4 -5 -3
1 0 -2 -2 0 0
2 4 7 11 28 12
3 7 4 11 28 21
4 3 -5 8 -15 9
Multiplication 6 a[n]b[n] 6
Scaling Scaling (or scalar multiplication) 3 a[n] Amplitude scaling by a constant c, y[n] = cx[n] is accomplished by multiplying every sample value by c.
AFMH
DSP_L1_T24
The unit sequence may be used to decompose an arbitrary sequence x[n] into a sum of weighted and shifted unit samples as follows:
x(n) = ... + x(1) (n + 1) + x(0) (n) + x(1) (n 1) + x( 2) (n 2) + ... = ... + 1. (n + 1) + 0. (n) + 1. ( n 1) + 2. (n 2) + 3. (n 3) + 2. ( n 4) + 1. (n 5) + ...
x[n]
x ( n) =
k =
x(k ) (n k )
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T25
Exercises
1 2 x(n ) = 3 0 n = 0 n = 1 n = 2 else
AFMH
DSP_L1_T26
Solution
There are several ways to derive the signal decomposition. (a) Express as a sum of weighted and shifted unit samples
x(n) = (n) + 2 (n 1) + 3 ( n 2) (n) = u (n) u (n 1) Use the fact: Therefore x(n) = u(n) u(n 1) + 2[u(n 1) u(n 2)]+ 3[u(n 2) u(n 3)]
= u(n) + u(n 1) + u(n 2) 3u(n 3) (b) Derive directly as follows: Decomposition should begin with a unit step which generates a value of 1 at index n=0. Because x(n) increases to a value of 2 at n=1, we must add a delayed unit step u(n-1). At n=2, x(n) again increases in amplitude by 1, so we add the delayed unit step u(n-2). We then bring the sequence back to zero for n>=3 by subtracting the delayed unit step 3u(n-3).
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T27
A common DSP application is the removal of noise from a signal corrupted by additive noise. A simple 3-point moving average algorithm is given by:
% Signal Smoothing by Averaging clf; % Generate random noise, d[n] R = 51; d = 0.8*(rand(R,1) - 0.5); % Generate uncorrupted signal, s[n] m = 0:R-1; s = 2*m.*(0.9.^m); % Generate noise corrupted signal, x[n] x = s + d'; subplot(2,1,1); plot(m,d','r-',m,s,'g--',m,x,'b-.'); xlabel('Time index n');ylabel('Amplitude'); legend('d[n] ','s[n] ','x[n] '); % do smoothing x1 = [0 0 x];x2 = [0 x 0];x3 = [x 0 0]; y = (x1 + x2 + x3)/3; subplot(2,1,2); plot(m,y(2:R+1),'r-',m,s,'g--'); legend( 'y[n] ','s[n] '); xlabel('Time index n');ylabel('Amplitude');
Ref: Program P1_5, DSP Lab using Matlab, Mitra
8 6 4 2 0 y[n] s[n]
Amplitude
10
15
35
40
45
50
AFMH
DSP_L1_T28
An amplitude modulated signal can be generated by modulating a highfrequency sinusoidal signal, xH [ n] = cos( H n) with a low-frequency sinusoidal signal, xL [ n] = cos( L n) . The resulting signal is of the form: where m is the modulation index.
Amplitude
% Generation of amplitude modulated seq clf; n = 0:100; m = 0.4;fH = 0.1; fL = 0.01; xH = sin(2*pi*fH*n); xL = sin(2*pi*fL*n); y = (1+m*xL).*xH; stem(n,y);grid; xlabel('Time index n');ylabel('Amplitude');
0.5
-0.5
-1
-1.5
10
20 AFMH
30
70
80
90
100
DSP_L1_T29
0.5
Amplitude
-0.5
-1
-1.5 0 10 20 30 40 50 Time index n AFMH Created: June 1999 Last update: July 2010 DSP_L1_T30 60 70 80 90 100
% Generation of a swept freq sinusoidal seq 1.5 n = 0:100; a = pi/2/400; b = 0; 1 arg = a*n.*n + b*n; x = cos(arg); 0.5 clf; stem(n, x); 0 axis([0,100,-1.5,1.5]); title('Swept-Frequency Sinusoidal Signal'); -0.5 xlabel('Time index n'); ylabel('Amplitude'); -1 grid; axis;
Amplitude -1.5 0 10 20
30
40 50 60 Time index n
70
80
90
100
Note: To generate a swept-frequency sinusoidal signal whose frequency increases linearly with time, the argument of the sinusoidal signal must be a quadratic function of time. Assume the argument is of the form an2 + bn (i.e. the angular frequency is 2an + b since the frequency is the derivative of its phase w.r.t. time). Solve for values of a and b from the given conditions (minimum & maximum angular frequencies).
Ref: Program P1_7new, DSP Lab using Matlab, Mitra
AFMH Created: June 1999 Last update: July 2010 DSP_L1_T31