0% found this document useful (0 votes)
2 views11 pages

Assignment2 Solution

Uploaded by

bobbykwok01
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)
2 views11 pages

Assignment2 Solution

Uploaded by

bobbykwok01
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/ 11

ELEG 3503: Introduction to Digital Signal Processing 2022-23 Second Term

Assignment 2 Due: Feb. 27

Problem 1
Calculate the N −point DFT for the following discrete-time signals with n = 0, 1, 2, ....
1. x[n] = (2n )cos(0.5πn) ; N = 3.
2. x[n] = tan π3 n (u[n] − u[n − 2]); N = 4.


3. x[n] = −0.5δ[n] + 3δ[n − 1] − 0.25δ[n − 6]; N = 7.

4. x[n] = ln [e + (u[n] − u[n − 1]) (1 − e)]; N = 3.

2
X
X[k] = x[n]W3kn
n=0

= 1 − 4e−j4πk/3

3
X
X[k] = x[n]W4kn
n=0
1
X π 
= tan n W4kn
n=0
3

= 3e−jπk/2

6
X
X[k] = x[n]W7kn
n=0

= −0.5 + 3e−j2πk/3 − 0.25e−j12πk/3

2
X
X[k] = x[n]W3kn
n=0
−j2πk/3
=e + e−j4πk/3
π 
= 2e−jπk cos k
3

1
Problem 2
Consider a discrete-time signal x̃[n] with period N . We know that mN is also a period of x̃[n] for any positive
integer m. Let X̃m [k] denotes the DFS coefficients of x̃[n] considered as a periodic sequence with period mN .
Clearly, when m = 1, X̃1 [k] is the typical DFS coefficients of x̃[n] that we are familiar with.
1. Express X̃3 [k] in terms of X̃1 [k].
2. Plot figure of the following discrete-time periodic signal

X ∞
X
x̃[n] = δ[n − 2k] + 2δ[n − 2k − 1].
k=−∞ k=−∞

3. Calculate X̃3 [k] and X̃1 [k] of the above signal x̃[n], and verify the result that you obtained in the first
question.

1
According to the definition, we have:
3N
X −1
kn
X̃3 [k] = x̃[n]W3N
n=0
N
X −1 2N
X −1 3N
X −1
kn kn kn
= x̃[n]W3N + x̃[n]W3N + x̃[n]W3N
n=0 n=N n=2N
N −1 N −1 N −1
k(n+N ) k(n+2N )
X X X
kn
= x̃[n]W3N + x̃[n + N ]W3N + x̃[n + 2N ]W3N
n=0 n=0 n=0

kn kn/3
Notice that N is the period of x[n] and W3N = WN . Then we have:

 −1
 NX
(kn/3)
X̃3 [k] = 1 + e−j2πk/3 + e−j4πk/3 x̃[n]WN
n=0

Let l = k/3:
−1
 NX
X̃3 [k] = 1 + e−j2πl + e−j4πl x̃[n]WNln
n=0

= 3X̃1 [l]
(
3X̃1 [k/3], k/3 is an integer
=
0, otherwise

2
Omitted. x̃[n] = 1 if n is even; x̃[n] = 2 if n is odd.

3
We observe that the period of x̃[n] is N = 2. Hence,
N
X −1
X̃1 [k] = x̃[n]WNkn
n=0
1
X
= x̃[n]e−jπkn
n=0
= x̃[0] + x̃[1]e−jπk
= 1 + 2(−1)k
(
3, k=0
=
−1, k = 1

2
On the other hand:
3N
X −1
kn
X̃3 [k] = x̃[n]W3N
n=0
5
π
X
= x̃[n]e−j 3 kn
n=0
 2π 4π
 k

= 1 + e−j 3 k + e−j 3 k 1 + 2(−1) 3
 2π 4π

= 1 + e−j 3 k + e−j 3 k X̃1 [k/3]

9,
 k=0
= −3, k = 3

0, k = 1, 2, 4, 5.

The result verifies the previously derived connection.

Problem 3
Suppose we have an aperiodic signal:
 n  n
5 4
x[n] = u[n] − u[n − 1].
6 5

We can construct a periodic signal based on x[n]:



X
x̃[n] = x[n + lN ].
l=−∞

Let N = 2,
1. plot figure of x[n] and calculate its DTFT X(ejω );

2. plot figure of x̃[n] and calculate its DFS X̃[k];


3. explain the relation between X̃[k] and X(ejω ).

1
For plotting the figure, we may use Matlab:

n = 0 : 100;
y = (5/6).n − (4/5).n ;
f igure
stem(n, y)

The DTFT of x[n] is given by



X
X ejω = x[n]e−jωn

n=−∞
∞  n ∞  n
X 5 X 4
= u[n]e−jωn − u[n − 1]e−jωn
n=0
6 n=0
5
−jω
1 4 e
= 5 −
5 1 − 45 e−jω
 
1− 6 e−jω

3
2
The figure can be approximately sketched by adding several shifted x[n] up. The DFS of x̃[n] is given by
1
X
X̃[k] = x̃[n]W2kn
n=0
1
X ∞
X
= x[n + 2l]W2kn
n=0 l=−∞

1  n+2l  n−1+2l !
X X 5 4 4
= u[n + 2l] − u[n − 1 + 2l] W2kn
n=0 l=−∞
6 5 5
1 X ∞  n+2l ∞  2l−1 X ∞  2l
X 5 kn
X 4 4 4 4
= W2 − − W2k
n=0 l=0
6 5 5 5 5
l=1 l=0
∞  2l X ∞  2l−1 ∞  2l
1  n
!
X 5 5 4 X 4 X 4
= W2kn − + W2k
6 n=0
6 5 5 5
l=0 l=1 l=0
1 + 65 W2k 4 45 + W2k
= 2 −
1 − 56 51− 4 2
 
5
1 4 W2k
= 5 −
5 1 − 45 W2k
 
1− 6 W2k
The last equality is obtained by multiplying the upper and lower sides of two fractions with the conjugates of
the numerators.

3
The relation is:
X̃[k] = X ejω

ω=2πk/N
.

Problem 4
Consider the following two finite-duration signals:
x1 [n] = 2ejω0 n , n = 0, 1, 2
x2 [n] = 3n , n = 0, 1, 2
1. Calculate the 3-point DFT, X1 [k], of x1 [n].
2. Calculate the 3-point DFT, X2 [k], of x2 [n].
3. Calculate y[n] = x1 [n]○x
3 2 [n] by 3-point circular convolution.
4. Calculate y[n] in the previous question by multiplying X1 [k] and X2 [k], and then performing an IDFT.
Compare the results of the two ways computing y[n].

1
By definition:
2
X
X1 [k] = x1 [n]W3kn
n=0

= 2 + 2ejω0 e−j2πk/3 + 2e2jω0 e−j4πk/3


= 2 + 4ej(ω0 −πk) cos(πk/3)

2
By definition:
2
X
X2 [k] = x2 [n]W3kn
n=0

= 1 + 3e−j2πk/3 + 9e−j4πk/3

4
3
By definition:
y[0] = 2 + 18ejω0 + 6e2jω0
y[1] = 6 + 2ejω0 + 18e2jω0
y[2] = 18 + 6ejω0 + 2e2jω0
We may write y[n] as:

y[n] = (2 + 18ejω0 + 6e2jω0 )δ[n] + (6 + 2ejω0 + 18e2jω0 )δ[n − 1] + (18 + 6ejω0 + 2e2jω0 )δ[n − 2]

4
We have:
  
X1 [k]X2 [k] = 2 + 2ejω0 e−j2πk/3 + 2e2jω0 e−j4πk/3 1 + 3e−j2πk/3 + 9e−j4πk/3
= (2 + 18ejω0 + 6e2jω0 ) + (6 + 2ejω0 + 18e2jω0 )e−j2πk/3 + (18 + 6ejω0 + 2e2jω0 )e−j4πk/3

Using the DFT pair δ[n] ⇐⇒ 1 and the time-shifting property of DFT, we can conclude that they are the same.
The circular convolution property is verified.

Problem 5 (Optional)
Suppose we have an aperiodic signal:  n
1
x[n] = u[n],
3
and its DTFT is denoted as X(ejω ). We also have a sequence y[n] which equals zero when n < 0 and n ≥ 10.
The 10-point DFT of y[n] is denoted as Y [k]. Suppose the following holds:

Y [k] = X(ej2πk/10 ),

which means Y [k] can be viewd as uniformly sampled from X(ejω ).


1. Determine y[n].
2. Is it true that y[((−n))10 ] = y[((10 − n))10 ]? Give your answer with justification.
3. Is Re{Y [k]} the DFT of (y[n] + y [((−n))10 ])/2? Give your answer with justification.

1
First calculate X(ejω ):

X
X ejω = x[n]e−jωn

n=−∞
∞  n
X 1
= e−jωn
n=0
3
1
=
1 − 13 e−jω
Then Y [k] is given by:

1 1 1 − 3110
Y [k] = X(ej2πk/10 )|ω=2πk/10 = =
1 − 31 e−j2πk/10 1 − 3110 1 − 13 e−j2πk/10
1
Since the 10-point DFT of 3n is
1 − 3110
1 − 13 e−j2πk/10
We have:
1
3n
y[n] = 1 , n = 0, 1, ..., 9
1− 310

5
2
Yes. The result holds for any finite-length sequence. By definition, ((−n))10 = −n − r10, for a proper integer
r such that 0 ≤ ((−n))10 < 10; ((10 − n))10 = 10 − n − k10 = −n − (k − 1)10, for a proper integer k − 1 such
that 0 ≤ ((−n))10 < 10. Clearly, r = k − 1 and the two expression are equal.

3
Yes. Since y[n] is real, then, by the symmetry property of DFT we have the IDFT of Re{Y [k]} as:
1
(y[n] + y [((−n))N ])
2

Problem 6
Use MATLAB, Python, or other programming languages that you prefer to handle this problem.
1. In the area of remote sensing, researchers detect materials by collecting waves reflected by these materials.
Different materials will reflect wave differently. Fig.1 shows some reference spectrums of the waves reflected
by some different materials.

• Load the waves of the first material ”material1 real.txt” and ”material1 imag.txt” for the signal’s
real part and imaginary part. Load the second material in the same way.
• Plot the magnitude of the two waves.
• Use FFT to calculate the spectrum of the two waves and plot the spectrum’s magnitude.
• Comparing the obtained spectrum with Fig.1, can you identify what the two materials are?

0.035
Vegetation
Soil
0.03 Water
Olivine

0.025
Magnitude

0.02

0.015

0.01

0.005

0
0 5 10 15 20 25 30 35 40 45 50
Spectrum

Figure 1: Material spectrum

2. • Load the data files ”sig1 16000.txt”, ”sig2 48000.txt”, and ”sig3 16000.txt”. Plot the three signals.
The number in the file name indicates the sampling frequency. For example, ”sig1 16000.txt” means
the sampling frequency of this signal is 16000Hz.
• Calculate the FFT of these signals and plot the spectrum’s magnitude. Make sure that your horizontal
axis is the frequency.
• Roughly indicate the frequencies or frequency regions that the energy of the signal is concentrated
around.
• The three signals are audios sampled from the real world: a piece of fricative sound, a piece of violin
sound, and a vowel sound. Can you give a guess which signal corresponds to which sound?

6
Hint: Concerning loading the data, let’s take ”sig1 16000.txt” as an example. For MATLAB, you may load the
data by:
x = load(”sig1 16000.txt”)
The signal is stored in the variable x. For Python, you may try

import numpy as np
x = np.loadtxt(”sig1 16000.txt”)

The signal is also stored in the variable x. You may also use reshape() to adjust your data dimension, like make
it be a column vector from a row vector.

1
They are vegetation and soil.

2
See Fig. 2

7
Signal 1, fricative Signal 2, violin
0.15 0.25

0.2

0.1
0.15

0.1
0.05

0.05
Value

Value
0 0

-0.05

-0.05
-0.1

-0.15
-0.1

-0.2

-0.15 -0.25
0 500 1000 1500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Index Index 10 4

(a) (b)

Signal 3, vowel
0.4

0.3

0.2
Value

0.1

-0.1

-0.2
0 1000 2000 3000 4000 5000 6000 7000 8000 9000
Index

(c)

Specturm of signal 1, fricative Specturm of signal 2, violin


5 1400

4.5
1200
4

3.5 1000

3
800
Magnitude

Magnitude

2.5

600
2

1.5 400

1
200
0.5

0 0
-8000 -6000 -4000 -2000 0 2000 4000 6000 8000 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
Frequency /Hz Frequency /Hz 10 4

(d) (e)

Specturm of signal 3, vowel

80

70

60
Magnitude

50

40

30

20

10

0
-8000 -6000 -4000 -2000 0 2000 4000 6000 8000
Frequency /Hz

(f)

Figure 2: Results for 6-2.


8
Problem 7 (Optional)
The Linear Frequency Modulation (LFM) pulse is widely used in areas like remote sensing and communication.
Mathematically, it has the form (simplified):

x(t) = exp jkπt2 , t ∈ [−T /2, T /2]




where k is a parameter to control the shape of the LFM signal; the duration of the pulse is T and the start
point of the signal is assumed to be t = −T /2. We can see that the frequency changes linearly with respect to
the time and that is also where the name LMF comes from. In practical systems, the LFM signal is handled in
discrete form. Hence, let’s denote the sampled version as:

x[n] = exp jkπ(−T /2 + n/fs )2 ,




where fs is the sampling frequency. Let k = 2 × 1010 , T = 5 × 10−5 , and fs = 1 × 107 . Use MATLAB, Python,
or other programming languages that you prefer to solve the following questions.

1. Plot the real and imaginary parts of x[n].


2. Use FFT to compute the discrete spectrum, X[k], of x[n] and plot the magnitude.
3. Let X̄[k] be the conjugate of X[k]. Obtain a new spectrum by Y [k] = X̄[k]X[k] and plot its magnitude.
4. Calculate the IFFT of Y [k], i.e., y[n], and plot the magnitude of y[n]. From the result, can you give
some explanation on why LMF pulse is suitable for radars to localize targets, i.e., measure the distance
between the radar and the target? (Hint: radar senses targets by sending a pulse and receiving the echo.
A high-energy pulse can sense far targets; a narrow pulse can distinguish close targets, i.e., high sensing
resolution. Yet, placing high energy directly on a narrow pulse isn’t easy.)

1
See Fig. 3

Real part Imaginary part


1 1

0.8 0.8

0.6 0.6

0.4 0.4

0.2 0.2
Magnitude

Magnitude

0 0

-0.2 -0.2

-0.4 -0.4

-0.6 -0.6

-0.8 -0.8

-1 -1
-5 -4 -3 -2 -1 0 1 2 3 4 5 -5 -4 -3 -2 -1 0 1 2 3 4 5
t/s 10 -5 t/s 10 -5

(a) (b)

Figure 3: Real and imaginary parts of x[n]

2
See Fig. 4

3
It is the same as Fig. 4. Because we just compensate the phase while the magnitude stays the same.

4
See Fig.5. It is interesting to find that the spectrum’s magnitude does not change much but the amplitude of
the time-domain signal changes a lot. When sensing targets, we want to make the pulse that we send out to
be as narrow as possible. Because imagine that, if the pulses last for very long periods, then we have difficulty

9
Specturm
60

50

40
Magnitude

30

20

10

0
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
f/Hz 10 6

Figure 4: X[k]

distinguishing two echos belonging to two targets who are not even that close with each other. In other words,
narrow pulses bring higher sensing resolution. However, if the pulse is too narrow, we have difficulty making
it contain high energy. If the pulses do not have much energy, then they might lose all their energy during
the transmit path and we receive very weak echoes or even nothing, which means we are not able to sense far
targets. So we want narrow pulses with high energy which is indeed challenging in practice. But, it can be
achieved by signal processing techniques shown in this problem. By sending a LFM signal which lasts for a long
period, we can put high energy into it. While, after processing, LFM can be very sharpe in the time-domain,
which means the sensing resolution can be very high.

10
Signal after processing
500

450

400

350

300
Magnitude

250

200

150

100

50

0
-5 -4 -3 -2 -1 0 1 2 3 4 5
t/s 10 -5

Figure 5: Signal after processing.

11

You might also like