0% found this document useful (0 votes)
11 views15 pages

DSP Lect L1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
11 views15 pages

DSP Lect L1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 15

Discrete-Time

Signals: Review 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, ... ...


n
and perform operations on these signals. -4 -3 -2 -1 0 1 2 3 5

x[n] x[n-N] x[n] x[-n] a[n] y[n] y[n]


-N x[n]
+/- x
x[n] x[2n] x[n] x[2n]
2 2 b[n] b[n] or scaling by c
J Tutorial:
!Solve problems related to the above.
<MATLAB Exercises
&Chap. 1, ‘’Digital Signal Processing, Sanjit K. Mitra.

AFMH Created: Last update: DSP_L1_T1


June 1999 July 2003

Discrete-Time
Signals: Review 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
denoted by x[n]. x[n] = (... 2 4 3 3 2 0 2 2 5...)

• x[n] is generally referred to as a
function of time. A d-t signal is x[n]
undefined for noninteger values of
n. ... ...
n
-4 -3 -2 -1 0 1 2 3 5

• A real-valued signal x[n] will be


represented graphically in the form
of a lollipop plot as shown.
AFMH Created: Last update: DSP_L1_T2
June 1999 July 2003

1
Discrete-Time
Signals: Review Generating a D-T Signal or Sequence

• 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/T s samples
per second produces the sampled A/D
signal x[n], which is related to xa(t) as xa(t)
follows: x[n]
Sampling
x[n] = xa(nT s) interval, Ts
• Not all d-t signals are obtained in this
manner. Eg. Daily stock market -4 -3 -2 -1 0 1 2 3 5
n
prices, population statistics, etc. AFMH Created: Last update: DSP_L1_T3
June 1999 July 2003

Discrete-Time
Signals: Review Complex Sequences
z[n] = (..., a + jb, c + jd ,...)
• 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[n] = Re{z[n]} + j Im{z[n]} z = a + jb
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: b z[n]
tan-1 b/a
|z[n]|2 = Re2{z[n]} + Im 2{z[n]}
• The phase may be found using a Re
arg{z[n]} = tan -1[Im{z[n]}/Re{z[n]}] -b
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: Last update: DSP_L1_T4
June 1999 July 2003

2
Discrete-Time Fundamental Sequences:
Signals: Review Unit Impulse Sequence δ [n]
• The unit impulse (or unit sample) sequence
δ [n], is defined as
δ[n]
1 n = 0 1
δ [ n] = 
0 n ≠ 0
-2 -1 0 1 2 3 n
• The delayed/shifted unit impulse/sample
sequence δ[n-k] is defined by

δ[n-k]
1 n = k
δ [n − k ] = 
0 n ≠ k
1
...

-2 -1 0 1 2 k n

AFMH Created: Last update: DSP_L1_T5


June 1999 July 2003

Discrete-Time Fundamental Sequences:


Signals: Review Unit Step Sequence u[n]
• The unit step sequence u[n], is defined as

1 n ≥ 0 u[n]
u[ n ] =  1
0 n < 0 ...
• Value of u[n] at n=0 is defined and equals
-2 -1 0 1 2 3 4 5 n
to unity (unlike c-t step function, u(t)).

• The shifted unit step sequence u[n-k] is


defined as u[n-k]

1 n ≥ k 1
u[ n − k ] =  ...
0 n < k
-2 -1 0 1 2 k n
AFMH Created: Last update: DSP_L1_T6
June 1999 July 2003

3
Discrete-Time Fundamental Sequences:
Signals: Review Unit Impulse Sequence
• From the definitions of
δ[n] and δ[n-k], it is x [ n ]δ [ n ] = x [ 0 ]δ [ n ]
readily seen that x [ n ]δ [ n − k ] = x [ k ]δ [ n − k ]

n
• Note that δ[n] and u[n]
are related by
u[n] = ∑ δ [ k ],
k = −∞

δ [ n ] = u [ n ] − u [ n − 1]
• Any sequence x[n] can

be expressed as
(see DSP_L1_T24) x[ n ] = ∑ x [ k ]δ [ n − k ]
k = −∞

AFMH Created: Last update: DSP_L1_T7


June 1999 July 2003

Discrete-Time Fundamental Sequences:


Signals: Review Complex Exponential Sequences
An exponential sequence is given as x[n] = A α n ,
A andα may real or complex numbers i.e.
α = exp(σ o + jω o ), and A = A exp( j φ ).

The complex exponential sequence is x[n] = A eσ o n + j (ωo n +φ )


of the form = Ae
σ on
cos(ω o n + φ ) + j A e
σ on
sin(ωo n + φ )

The real sinusoidal sequence with a x[n] = A cos(ω o n + φ )


constant amplitude is of the form
amplitude angular frequency initial phase

For x[n] (with σo=0 for complex seq) ω0 m


= m = positiveinteger
to be periodic with period N, ω0 must 2π N
satisfy the following condition
The smallest N yields the  2π 
N 0 =  
fundamental period of sequence,N0  ω0 
AFMH Created: Last update: DSP_L1_T8
June 1999 July 2003

4
Discrete-Time Fundamental Sequences:
Signals: Review Complex-valued Exponential Sequences

2e −12 n cos 212πn


1

% Generation of a complex exp. sequence 2


Real part

x[n] = 2 exp(− 121 + j π6 )n


1
clf;

Amplitude
c = -(1/12)+(pi/6)*i; 0

K = 2; -1

n = 0:40; -2
x = K*exp(c*n); 0 5 10 15 20
Time index n
25 30 35 40

subplot(2,1,1);
2e −12 n sin 212πn
1

stem(n,real(x)); 2
Imaginary part

xlabel('Time index n');ylabel('Amplitude');


title('Real part');

Amplitude
1

subplot(2,1,2);
0
stem(n,imag(x));
xlabel('Time index n');ylabel('Amplitude'); -1
title('Imaginary part'); 0 5 10 15 20 25 30 35 40
Time index n

Ref: Program P1_2, DSP Lab using Matlab, Mitra AFMH Created: Last update: DSP_L1_T9
June 1999 July 2003

Discrete-Time Fundamental Sequences:


Signals: Review Period Complex-valued Exponential Sequences

% Generate periodic complex sequence Real part Imaginary part


1 1
% x[n] = exp( j 10
π
)n
0.5 0.5
n=[0:40];
x=exp((j*pi/10)*n); 0 0

subplot(2,2,1); -0.5 -0.5

stem(n, real(x)) % real part -1 -1


subplot(2,2,2); 0 10 20 30 40 0 10 20 30 40

stem(n, imag(x)) % imaginary part Magnitude Phase


subplot(2,2,3); 1 200

stem(n, abs(x)) % magnitude 0.8 100

subplot(2,2,4); 0.6
0
stem(n, angle(x)*(180/pi)) 0.4
-100
% phase in degrees 0.2

0 -200
0 10 20 30 40 0 10 20 30 40

Ref: Program P1_2new AFMH Created: Last update: DSP_L1_T10


June 1999 July 2003

5
Discrete-Time Fundamental Sequences:
Signals: Review Real-valued Exponential Sequences
% Generation of a real exp.l sequence
clf;
n = 0:35; a = 1.2; K = 0.2;
x = K*a.^n;
stem(n,x);
120 xlabel('Time index n');ylabel('Amplitude');

100

80
Amplitude

60

40

20

0
0 5 10 15 20 25 30 35
Time index n

Ref: Program P1_3, DSP Lab using Matlab, Mitra AFMH Created: Last update: DSP_L1_T11
June 1999 July 2003

Discrete-Time Fundamental Sequences:


Signals: Review Sinusoidal Sequences
• A sinusoidal sequence can be expressed as

x[n] = A cos(ω 0 n + θ )
If n is dimensionless, then both ω0 and θ have units of radians.

x[n]=cos(πn/6)

-6 6
-12 -9 -3 0 3 9 12 n

Sequence above is periodic with fundamental period 12.


AFMH Created: Last update: DSP_L1_T12
June 1999 July 2003

6
Discrete-Time Fundamental Sequences:
Signals: Review Sinusoidal Sequences

% Generation of a sinusoidal sequence


n = 0:40; Sinusoidal Sequence
2
f = 0.1;
phase = 0; 1.5

A = 1.5; 1
arg = 2*pi*f*n - phase;
0.5
x = A*cos(arg);

Amplitude
clf; % Clear old graph 0

stem(n,x);% Plot the generated sequence


-0.5
axis([0 40 -2 2]);
grid; -1

title('Sinusoidal Sequence'); -1.5


xlabel('Time index n');
ylabel('Amplitude'); -2
0 5 10 15 20 25 30 35 40
axis; Time index n

Ref: Program P1_4, DSP Lab using Matlab, Mitra AFMH Created: Last update: DSP_L1_T13
June 1999 July 2003

Discrete-Time
Signals: Review Symmetric Sequences

• A real-valued sequence x[n] is said to be even if, x[n]


for all n
» x[n] = x[-n]
• whereas it is said to be odd if, for all n
0 n
» x[n] = -x[-n]
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 0 n
follows:
x[n] = xe[n] + xo[n], Example:
where x[n]=(3 6 2 10 1 8 5)
xe[n] = 1/2 {x[n]+x[-n]}, x[-n]=(5 8 1 10 2 6 3)
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: Last update: DSP_L1_T14


June 1999 July 2003

7
Discrete-Time
Signals: Review Symmetric Sequences (Complex)

• A complex sequence x[n] is said to be Im

conjugate symmetric (see note below) if, for


a + jb
all n
Re
» x[n] = x*[-n]
a − jb
• whereas it is said to be conjugate Im

antisymmetric if, for all n


− a + jb a + jb
» x[n] = -x*[-n]
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: Last update: DSP_L1_T15
June 1999 July 2003

Discrete-Time
Signals: Review Periodic and Aperiodic Sequences

• 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+N] for all n x[n]

Sequence repeats itself


every N samples
See TP DSP_L1-T8
-N 0 N n
• 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 DSP_L1_T16
June 1999 July 2003

8
Discrete-Time
Signals: Review 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.125πn)


(b) x[n] = Re{e jnπ /12 } + Im{e jnπ / 18}
(c) x[n] = sin(π + 0.2n)
π
j n
(d) x[n] = e 16 cos(nπ / 17)

AFMH Created: Last update: DSP_L1_T17


June 1999 July 2003

Discrete-Time
Signals: Review Solutions

Ê (a) x[ n] = cos(0.125πn)
Because 0.125π = π/8,

From TP DSP_L1_T8, we have ω0 = π/8, and

For x[n] to be periodic with period N, ω0 must satisfy the


following condition ω0/2π = m/N (=1/16)

Therefore, cos(π/8 n) = cos(π/8 (n+16))


2π 2π
N0 = = = 16
x[n] is periodic with fundamental period N 0 = 16. ω0 π
8

Try plotting - adapt Matlab code on DSP_L1_T13 AFMH Created:


June 1999
Last update:
July 2003
DSP_L1_T18

9
Discrete-Time
Signals: Review Solutions

jn π / 12 jn π / 18
Ê (b) x[n ] = Re{e } + Im{e }
Here we have the sum of two periodic signals
x[ n] = cos( nπ / 12 ) + sin( nπ / 18)
Note: If x1[n] is a sequence with period N1, and x2[n] is another sequence with period
N2, the sum x[n]=x1[n]+x2[n] will always be periodic with a fundamental period
N1 N 2
N= 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

Therefore, the period of ω 01 = π /12, ω 02 = π /18


the sum is N1 = π2/π12 = 24, N 2 = π2/π18 = 36
N = gcd( 24,36 ) = =
(24 )(36 ) ( 24 )(36 )
12
72
AFMH Created: Last update: DSP_L1_T19
June 1999 July 2003

Discrete-Time
Signals: Review Solutions

Ê (c) x[n] = sin(π + 0.2n)


In order for this sequence to be periodic, we must be able
to find a value for N such that

sin(π + 0.2n) = sin(π + 0.2(n + N ))


The sine function is periodic with a period 2π.
Therefore, 0.2N must be an integer multiple of 2π.
However, because π is an irrational number, no integer
value of N exists that will make the equality true.
Thus, this sequence is aperiodic.

AFMH Created: Last update: DSP_L1_T20


June 1999 July 2003

10
Discrete-Time
Signals: Review Solutions
π
j n
Ê (d) x[n ] = e 16 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/π16 = 32, N 2 = π2/π17 = 34
N = gcd( 32 ,34 ) = =
( 32 )(34 ) (32 )(34 )
2
544

AFMH Created: Last update: DSP_L1_T21


June 1999 July 2003

Discrete-Time Signal Manipulation:


Signals: Review Shifting, Reversal, Time scaling
• Note: The operations below are order-dependent. x[n]
• Shifting
– If y[n]=x[n-n0], x[n] is shifted to the right by -2-1 0 1 2 3 4 5 6 n
n0 samples (delay), given n0 positive x[n-2]

• Reversal -2-1 0 1 2 3 4 5 6 n
– Given y[n]=x[-n] (simply involves “flipping”
x[-n]
the sequence x[n] w.r.t. to index n)

• Time scaling -8-7 -6-5-4 -3-2 -10 n


– Given y[n]=x[Mn] or y[n]=x[n/N] where M
and N are positive integers.
Down-sampling Up-sampling by
x[2n] x[n/2]
by a factor of 2 a factor of 2

-2-1 0 1 2 3 4 5 6 n -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 n
AFMH Created: Last update: DSP_L1_T22
June 1999 July 2003

11
Discrete-Time Signal Manipulation:
Signals: Review Addition, Multiplication, Scaling
• Addition
– The sum of 2 sequences,
y[n]=a[n]+b[n] is formed by the n -1 0 1 2 3 4
pointwise addition of the two
sequences.
a[n] 2 -1 0 4 7 3

• Multiplication (or modulation) b[n] 3 5 -2 7 4 -5


– The product of 2 sequences,
y[n]=a[n]b[n] is formed by the Addition 5 4 -2 11 11 8
pointwise product of the two a[b]+b[n]
sequences. Multiplication 6 -5 0 28 28 -15
a[b]b[n]

• Scaling (or scalar multiplication) Scaling 6 -3 0 12 21 9


3 a[n]
– Amplitude scaling by a constant c,
y[n] = cx[n] is accomplished by
multiplying every sample value by c.
AFMH Created: Last update: DSP_L1_T23
June 1999 July 2003

Discrete-Time Signal Manipulation:


Signals: Review Shifting, Reversal, Time scaling
• 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) + ...

x[n]

-2 -1 0 1 2 3 4 5 6 7 8 9 10 11 n

• This decomposition may be written concisely as:



x( n ) = ∑ x(k )δ (n − k )
k = −∞
AFMH Created: Last update: DSP_L1_T24
June 1999 July 2003

12
Discrete-Time
Signals: Review Exercises

Ë Express the sequence 1 n = 0


2 n = 1

x(n) = 
3 n = 2
 0 else

as a sum of scaled and shifted unit steps.

AFMH Created: Last update: DSP_L1_T25


June 1999 July 2003

Discrete-Time
Signals: Review 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)
Use the fact: δ ( n) = u ( n) − u ( n − 1)
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: Last update: DSP_L1_T26
June 1999 July 2003

13
Discrete-Time Application Example #1 -
Signals: Review Signal Smoothing
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 1
clf;
y[n] = ( x[ n − 1] + x[ n] + x[n + 1])
3
% Generate random noise, d[n]
R = 51; d = 0.8*(rand(R,1) - 0.5); 8
d[n]
% Generate uncorrupted signal, s[n] 6
s[n]

Amplitude
x[n]
m = 0:R-1; s = 2*m.*(0.9.^m); 4

% Generate noise corrupted signal, x[n] 2


x = s + d'; 0
subplot(2,1,1); -2
plot(m,d','r-',m,s, 'g--',m,x,'b-.'); 0 5 10 15 20 25 30
Time index n
35 40 45 50

xlabel('Time index n');ylabel('Amplitude'); 8


legend('d[n] ','s[n] ','x[n] '); y[n]
s[n]
% do smoothing Amplitude
6

x1 = [0 0 x];x2 = [0 x 0];x3 = [x 0 0]; 4


y = (x1 + x2 + x3)/3;
2
subplot(2,1,2);
plot(m,y(2:R+1),'r-',m,s, 'g--'); 0
0 5 10 15 20 25 30 35 40 45 50
legend( 'y[n] ','s[n] '); Time index n
xlabel('Time index n');ylabel('Amplitude');
Ref: Program P1_5, DSP Lab using Matlab, Mitra AFMH Created: Last update: DSP_L1_T27
June 1999 July 2003

Discrete-Time Application Example #2 -


Signals: Review Amplitude Modulation
An amplitude modulated signal can be generated by modulating a high-
frequency sinusoidal signal, x H [ n] = cos(ω H n) with a low-frequency
sinusoidal signal, x L [n ] = cos(ω L n) . The resulting signal is of the form:
y[n ] = A(1 + m.xL [n ]) xH [ n] = A(1 + m.cos(ω L n)) cos(ω H n )
where m is the modulation index.
1.5

% Generation of amplitude modulated seq 1


clf;
n = 0:100; 0.5
m = 0.4;fH = 0.1; fL = 0.01;
Amplitude

0
xH = sin(2*pi*fH*n);
xL = sin(2*pi*fL*n); -0.5
y = (1+m*xL).*xH;
stem(n,y);grid; -1
xlabel('Time index n');ylabel('Amplitude');
-1.5
0 10 20 30 40 50 60 70 80 90 100
Time index n

Ref: Program P1_6, DSP Lab using Matlab, Mitra AFMH Created: Last update: DSP_L1_T28
June 1999 July 2003

14
Discrete-Time Application Example #2 -
Signals: Review Amplitude Modulation

y[n ] = A(1 + m.xL [n ]) xH [ n] = A(1 + m.cos(ω L n)) cos(ω H n )


1.5

0.5
Amplitude

-0.5

-1

-1.5
0 10 20 30 40 50 60 70 80 90 100
Time index n

AFMH Created: Last update: DSP_L1_T29


June 1999 July 2003

Discrete-Time Application Example #3 -


Signals: Review Swept Frequency Sinusoidal Sequence
% Generation of a swept freq sinusoidal seq 1.5 Swept -Frequency Sinusoidal Signal

n = 0:100; a = pi/2/400; b = 0;
arg = a*n.*n + b*n; 1

x = cos(arg);
0.5
clf;
Amplitude

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;
-1.5
0 10 20 30 40 50 60 70 80 90 100
Time index n

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: Last update: DSP_L1_T30
June 1999 July 2003

15

You might also like