Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions...

28
18-290 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 2017 Homework 11 Solutions Part One 1. (16 points) Let x(t) and y(t) be two signals that have FT X () = 0 for |ω| x and Y () = 0 for |ω| y , respectively. For each of the signals listed below, find the Nyquist sampling period T s in terms of ω x and ω y , such that the sampled signal has no aliasing. Assume ω y x . (a) z 1 (t)= x(t)+2y(t) (b) z 2 (t)= x(t) * y(t) (c) z 3 (t)= x(t)y(t) (d) z 4 (t)= x(t) cos(2ω y t)+ y(t) Solution: (a) T s = π ωy According to the linearity property of FT, Z 1 ()= X ()+2Y () Therefore ω M = ω y , and so ω s =2ω y . (b) T s = π ωx According to the convolution property of FT, Z 2 ()= X ()Y () Therefore ω M = ω x , and so ω s =2ω x . (c) T s = π ωx+ωy According to the multiplication property of FT, Z 3 ()= 1 2π X () * Y () If X () and Y () are two boxes, the result of convolution would be a trapezoid ranging from -ω x -ω y to ω x +ω y . Therefore ω M = ω x +ω y , and so ω s = 2(ω x +ω y ). (d) T s = π 2ωy +ωx Note that z 4 (t)= 1 2 x(t)(e j 2ωy t + e -j 2ωy t )+ y(t). According to the frequency shift and linearity property of FT, Z 4 ()= 1 2 X (j (ω +2ω y )) + 1 2 (j (ω - 2ω y )) + Y () Therefore ω M =2ω y + ω x , and so ω s = 2(2ω y + ω x )

Transcript of Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions...

Page 1: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

18-290Signals and SystemsProfs. Byron Yu and Pulkit Grover Fall 2017

Homework 11 Solutions

Part One

1. (16 points) Let x(t) and y(t) be two signals that have FT X(jω) = 0 for |ω| > ωxand Y (jω) = 0 for |ω| > ωy, respectively. For each of the signals listed below, find theNyquist sampling period Ts in terms of ωx and ωy, such that the sampled signal hasno aliasing. Assume ωy > ωx.

(a) z1(t) = x(t) + 2y(t)

(b) z2(t) = x(t) ∗ y(t)

(c) z3(t) = x(t)y(t)

(d) z4(t) = x(t) cos(2ωyt) + y(t)

Solution:

(a) Ts = πωy

According to the linearity property of FT,

Z1(jω) = X(jω) + 2Y (jω)

Therefore ωM = ωy, and so ωs = 2ωy.

(b) Ts = πωx

According to the convolution property of FT,

Z2(jω) = X(jω)Y (jω)

Therefore ωM = ωx, and so ωs = 2ωx.

(c) Ts = πωx+ωy

According to the multiplication property of FT,

Z3(jω) =1

2πX(jω) ∗ Y (jω)

If X(jω) and Y (jω) are two boxes, the result of convolution would be a trapezoidranging from −ωx−ωy to ωx+ωy. Therefore ωM = ωx+ωy, and so ωs = 2(ωx+ωy).

(d) Ts = π2ωy+ωx

Note that z4(t) = 12x(t) (ej2ωyt + e−j2ωyt) + y(t). According to the frequency shift

and linearity property of FT,

Z4(jω) =1

2X (j(ω + 2ωy)) +

1

2(j(ω − 2ωy)) + Y (jω)

Therefore ωM = 2ωy + ωx, and so ωs = 2(2ωy + ωx)

Page 2: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

2 Homework 11 Solutions

2. (12 points) Consider the continuous-time signal x(t) with FT as shown below. Sketch

the FT of the sampled signal xs(t) = x(t)p(t), where p(t) =∞∑

n=−∞δ(t − nTs) for the

following sampling periods.

(a) (5 points) Ts = 18

(b) (5 points) Ts = 12

(c) (5 points) Ts = 2

−4π −3π −2π 2π 3π 4π

1

2

ω

X(jω)

Solution: Consider p(t) =∞∑

k=−∞

δ(t − kTs), the impulse train used to sample x(t).

Then

P (jω) =2π

Ts

∞∑k=−∞

δ(ω − 2πk

Ts)

xs(t) = x(t)yδ(t)

Xs(jω) =1

2πX(jω) ∗ Yδ(jω)

=1

2πX(jω) ∗ 2π

Ts

∞∑k=−∞

δ(ω − 2πk

Ts)

=1

TsX(jω) ∗ (

∞∑k=−∞

δ(ω − 2πk

Ts))

=1

Ts

∞∑k=−∞

X(j(ω − 2πk

Ts))

Page 3: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 3

(a)

Ts =1

8

Xs(jω) = 8∞∑

k=−∞

X(j(ω − 16kπ))

−13π −3π 3π 13π

1

2

3

4

5

6

7

8

ω

Xs(jω)

(b)

Ts =1

2

Xs(jω) = 2∞∑

k=−∞

X(j(ω − 4kπ))

−10π −5π 5π 10π

1

2

3

4

5

6

7

8

ω

Xs(jω)

Page 4: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

4 Homework 11 Solutions

(c)

Ts = 2

Xs(jω) =1

2

∞∑k=−∞

X(j(ω − kπ))

−10π −5π 5π 10π

1

2

3

4

5

6

7

8

ω

Xs(jω)

Page 5: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 5

3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20πt)+cos(50πt). Thesignal is passed through a sampling and ideal reconstruction system shown below.Determine the output y(t) for the following sampling periods:

(a) (4 points) Ts = 180

(b) (4 points) Ts = 150

(c) (4 points) Ts = 140

(d) (2 points) For which of the above values of Ts does y(t) = x(t) hold? Justifyyour answer.

(Hint: Consider the Fourier transform of each of the relevant signals.)

× H(jω) = Ts, |ω| ≤ πTs

x(t)

p(t) =∑∞

k=−∞ δ(t− kTs)

xp(t) y(t)

Solution: We start with a general form.

xp(t) = x(t)p(t)

Xp(jω) =1

2πX(jω) ∗ P (jω)

=1

2ππ(δ(ω − 20π) + δ(ω + 20π) + δ(ω − 50π) + δ(ω + 50π)) ∗ 2π

Ts

∞∑k=−∞

δ(j(ω − 2kπ

Ts))

Ts

∞∑k=−∞

(δ(ω − 20π − 2kπ

Ts) + δ(ω + 20π − 2kπ

Ts)

+ δ(ω − 50π − 2kπ

Ts) + δ(ω + 50π − 2kπ

Ts))

and also

Y (jω) = Xp(jω)H(jω) = TsXp(jω)(u(ω +π

Ts)− u(ω − π

Ts))

Page 6: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

6 Homework 11 Solutions

(a) Ts = 180

. πTs

= 80π

Xp(jω) = 80π∞∑

k=−∞

(δ(ω − 20π − 160πk) + δ(ω + 20π − 160πk))

+ 80π∞∑

k=−∞

(δ(ω − 50π − 160πk) + δ(ω + 50π − 160πk))

H(jω) =1

80(u(ω + 80π) + u(ω − 80π))

Y (jω) = π(δ(ω + 20π) + δ(ω − 20π)) + π(δ(ω + 50π) + δ(ω − 50π))

y(t) = cos(20πt) + cos(50πt)

(b) Ts = 150

. πTs

= 50π

Xp(jω) = 50π∞∑

k=−∞

(δ(ω − 20π − 100πk) + δ(ω + 20π − 100πk))

+ 50π∞∑

k=−∞

(δ(ω − 50π − 100πk) + δ(ω + 50π − 100πk))

H(jω) =1

50(u(ω + 50π) + u(ω − 50π))

Y (jω) = π(δ(ω + 20π) + δ(ω − 20π)) + 2π((δ(ω + 50π) + δ(ω − 50π))

y(t) = cos(20πt) + 2 cos(50πt)

(c) Ts = 140

. πTs

= 40π

Xp(jω) = 40π∞∑

k=−∞

(δ(ω − 20π − 80πk) + δ(ω + 20π − 80πk))

+ 40π∞∑

k=−∞

(δ(ω − 50π − 80πk) + δ(ω + 50π − 80πk))

H(jω) =1

40(u(ω + 40π) + u(ω − 40π))

Y (jω) = π(δ(ω + 20π) + δ(ω − 20π)) + π(δ(ω + 30π) + δ(ω − 30π))

y(t) = cos(20πt) + cos(30πt)

(d) y(t) = x(t) is valid only in (a), when Ts = 180

, which prevents aliasing.

Page 7: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 7

4. (10 points) In the system shown below, two continuous-time signals x1(t) and x2(t)are multiplied together and the product w(t) is sampled by a periodic impulse trainp(t). x1(t) and x2(t) have the following FT:

X1(jω) =

1 |ω| ≤ 500

0 otherwise

X2(jω) =

1 |ω − 550| ≤ 50

0 otherwise

Determine the maximum sampling interval Ts such that w(t) can be recovered fromwp(t).

× ×x1(t)

x2(t)

w(t)

p(t) =∑∞

n=−∞ δ(t− nTs)

wp(t)

Solution:

w(t) = x1(t)x2(t)

=⇒ W (jω) =1

2πX1(jω) ∗X2(jω)

=⇒ W (jω) 6= 0, |ω| ≤ ω1 + ω2,

where ω1 and ω2 are the bandwidths of x1(t) and x2(t). From the given data, ω1 = 500and ω2 = 600. Hence,

ωW = 500 + 600 = 1100.

Nyqyuist sampling rate requires that ωs ≥ 2200. Hence,

Ts =2π

ωs

1100,

Page 8: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

8 Homework 11 Solutions

which guarantees that w(t) can be recovered from wp(t).

As the frequency spectrum is only one sided, note that a sampling rateof ws = 1100 is actually sufficient to sample and then reconstruct back thesignal - but the filter that we need afterwards has to be one-sided too.For signals with unequal frequency spectrum on both sides of the axis, saylength wb1 and wb2, then a Nyquist rate of wb1 + wb2 is sufficient. Full creditis given to either solutions.

Page 9: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 9

5. (18 points) The sampling scheme discussed in class is what is typically called idealsampling. In an ideal sampler, a bandlimited CT signal x(t) is sampled to obtain aDT signal x[n] such that

xideal[n] = x(nTs),

where Ts is the sampling period (in seconds).

In this problem, we study a non-ideal sampling scheme that is often used since itenables a simpler hardware implementation. Consider a bandlimited signal x(t) withbandwidth W rad/second (i.e. X(jω) = 0 for |ω| > W ). We obtain a discrete-timesignal xni[n] as follows:

xni[n] =1

2∆

∫ nTs+∆

nTs−∆

x(τ)dτ

That is, as opposed to simply selecting the value of the signal at t = nTs, the non-idealsampler averages the signal over a small duration nTs −∆ ≤ t ≤ nTs + ∆.

The goal is to analyze non-ideal sampling by studying reconstruction of x(t) fromnon-ideal samples xni[n]. The figure below illustrates our approach.

ideal sampling x(t) xni[n]box filter

h(t) z(t)

h(t)

t

1/(2)

We will need the following definitions.

(i) Let x(t)FT←−−→ X(jω) and xni[n]

DTFT←−−→ Xni(ejΩ);

(ii) Let h(t) = (u(t+ ∆)− u(t−∆))/(2∆) be a box function, centered at the origin,with a width of 2∆ and height 1/(2∆).

Now answer the following:

(a) (2 points) Define z(t) = x(t) ∗ h(t). Letting z(t)FT←−−→ Z(jω), express Z(jω)

in terms of X(jω) and ∆.

(b) (3 points) Let z[n] = z(nTs). Derive the relationship between x(t) and xni[n].

(c) (3 points) Evaluate Xni,δ(jω), the FT of xni,δ(t) in terms of Ts and Z(jω), where

xni,δ(t) =∞∑

n=−∞xni[n]δ(t− nTs).

(d) (4 points) Now we combine (a), (b), and (c) to characterize non-deal sampling.Express Xni(e

jΩ) in terms of X(jω), Ts, and ∆. (Hint: Use the relationship,Ω = ωTs.)

Page 10: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

10 Homework 11 Solutions

(e) (3 points) What are the largest values of ∆ and Ts for which we can perfectlyrecover x(t) from xni[n]. (Hint: Draw the FT of the signals. Also, you will havetwo conditions on Ts. One condition on Ts and one on ∆ is sufficient.)

(f) (3 points) Let ∆ = Ts/2 and Ts = π/W . Given X(jω) as below, draw H(jω),Z(jω) and Xni(e

jΩ).

−W W

1

ω

X(jω)

(Solution:)

(a) Let h(t)FT←−−→ H(jω). Since h(t) is a box filter, H(jω) is a sinc function:

H(jω) =2 sin(ω∆)

2∆ω= sinc

(ω∆

π

)Since z(t) = x(t) ∗ h(t),

Z(jω) = X(jω)H(jω) = X(jω)sinc

(ω∆

π

)(b) From the convolution integral,

z(t) =

∫ +∞

−∞h(τ)x(t− τ)dτ (definition of convolution)

=1

2∆

∫ ∆

−∆

x(t− τ)dτ (substituting in h(t))

=1

2∆

∫ t+∆

t−∆

x(η)dη (defining η = t− τ)

Since xni is simply an ideally sampled version of z(t), we have,

xni[n] = z(nTs).

Page 11: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 11

(c)

xni[n] = z(nTs)

=⇒ xni,δ(t) = z(t)p(t)

=⇒ xni,δ(t) = z(t)∞∑

n=−∞

δ(t− nTs)

=⇒ Xni,δ(jω) =1

TsZ(jω) ∗

∞∑k=−∞

δ

(ω − 2π

Tsk

)

=⇒ Xni,δ(jω) =1

Ts

∞∑k=−∞

Z

(j

(ω − 2π

Tsk

))

Now, using the relationship Ω = ωTs, we have,

Xni(ejΩ) =

1

Ts

+∞∑k=−∞

Z

(j

Ω− k2π

Ts

)(d)

Xni =1

Ts

+∞∑k=−∞

Z

(j

Ω− k2π

Ts

)

=1

Ts

+∞∑k=−∞

X

(j

Ω− k2π

Ts

)H

(j

Ω− k2π

Ts

)

Xni(ejΩ) =

1

Ts

+∞∑k=−∞

X

(j

Ω− k2π

Ts

)sinc

((Ω− 2πk)∆

Tsπ

)(e) To avoid aliasing, the copies of X(jω) should not overlap. Since Ω = ωTs, the

copy of X(·) for k = 0 has non-zero support for |Ω| ≤ WTs. Hence, to avoidaliasing, we would want

2π −WTs > WTs =⇒ Ts <π

W

In essence, we have the same constraint on the sampling period Ts as in the idealcase to avoid aliasing.

Further, we do not want any of the nulls of the sinc function inside |ω| ≤ W . Thefirst null of the sinc happens for ω = π/∆, and hence, we want

π

∆> W =⇒ ∆ <

π

W= Ts

This does not necessarily give two conditions on Ts - it gives one con-dition on Ts and one on ∆. No need for last step π

W= Ts

Page 12: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

12 Homework 11 Solutions

(f) H(jω) = sinc(ω∆π

)= sinc

2W

)and Z(jω) = X(jω)H(jω).

−4W −2W 2W 4W

−1

1

0 ω

H(jω)

−4W −2W 2W 4W

−1

1

0 ω

Z(jω)

Page 13: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 13

−4π −2π 2π 4π

1Ts

0 Ω

Xni(jΩ)

Page 14: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

14 Homework 11 Solutions

Part Two

6. (14 points) Consider the following signal in continuous time

x(t) = sinc2(t)

We would like to store x(t) in a computer, but we cannot directly store a continuous-time signal in a computer. Instead, we need to sample to convert x(t) into a discrete-time signal x[n].

(a) (4 points) Submit: Approximately plot sinc2(t) as a function of timeusing pencil and paper.

(b) (5 points) Now, use MATLAB to sample the continuous-signal with a samplingperiod Ts = 1, Ts = 0.7, Ts = 0.5 and Ts = 0.2. In other words, define x[n] =x(nTs). As an example, see the code below.

Ts = 1;

t_sample = -10:Ts:10;

xs = sinc(t_sample).^2;

Answer: By visual examination, at what Ts does xs no longer look like sinc2(t)?Submit: Plots of xs for Ts = 1,Ts = 0.7, Ts = 0.5, Ts = 0.2.

(c) (5 points) Now, let us look at the frequency-domain representations of thesesampled signals.

fxs = fft(xs);

figure;

plot(t_sample, fftshift(abs(fxs)));

Answer: At what Ts do the copies in the frequency domain begin to overlap?How does this relate to the highest frequency component in x(t)? Does this valueof Ts match what you reported in b?

Submit: Frequency-domain representations of four signals, sampled with inter-vals Ts = 1, Ts = 0.7, Ts = 0.5 and Ts = 0.2.

Solution:

(a) Students should draw this on paper but the MATLAB plot is shown below.

Page 15: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 15

(b) Plots of signal sampled with various rates:

Page 16: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

16 Homework 11 Solutions

Page 17: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 17

For Ts >= 0.7 the signal no longer looks like x(t).

(c) Plots of FFT of sampled signals are as shown below.

Page 18: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

18 Homework 11 Solutions

Page 19: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 19

We can see the edges of the FFT corresponding to Ts = 0.7 are distorted- thismeans overlap is taking place. Highest frequency/Bandwidth of in x(t) is 1 Hz.

Hence, the Nyquist frequency should be 2 Hz. This corresponds to Ts =1

2= 0.5s.

Hence, for Ts greater than 0.5, there will be overlap in the frequency domain.

Page 20: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

20 Homework 11 Solutions

7. (15 points) Consider the continuous-time signal from Problem 3, x(t) = cos(20πt) +cos(50πt). We reconstructed x(t) from its samples for different values of the samplingperiod Ts. In this problem we will verify the findings in Matlab.

(a) (5 points) We will first represent x(t) in Matlab using fine time resolution (Ts =1

880seconds) as a proxy for the continuous-time signal x(t). The following defines

the time indices Tsc for a duration of 2 seconds. Create a Matlab array of timesamples for a duration of 2 seconds:

Tsc = 1 / 880;

tsc = -1:Tsc:1-Tsc;

Create a plot of x(t) using the time indices Tsc and the plot function.

Then sample the signal x(t) with sampling periods Ts = 180, 1

50and 1

40seconds.

For each Tsc, plot the sampled signal in the time domain using the plot function.Use function disFreq(xp,1/Ts) provided to plot its DTFS.

Answer: For each Ts,

• Does the sampled signal look the same as the original signal x(t)? If not,what are the differences?

• What are the frequency components of the sampled signal? Are the frequen-cies of the output cosine signals the same as Problem 3?

Submit: Plots of the sampled signal and its DTFS for each value of Ts.

(b) (5 points) For reconstruction, we passed the sampled signal into an ideal lowpass filter in problem 3. This is the same as convolution between the sampledsignal and a sinc function (i.e., the impulse response of the lowpass filter) inthe time domain, which is also called sinc interpolation. However, to create anideal low pass filter, we would need a sinc function that extends infinitely intime. In real-world applications, we need to use a truncated sinc function forreconstruction, and the non-ideal low pass filter may allow unwanted frequencycomponents to leak into the reconstructed signal. Here, we will see the effect ofusing different truncations of sinc function for reconstruction.

First, we need to define the sinc function in Matlab, whose frequency domainrepresentation is H(jω) = 1, |ω| ≤ π

Ts. Create a plot of x(t) using time indices Tsc

and the function plot. Write a new function my sinc that takes in time values tand cut-off frequency wc and outputs the sinc function.

function x = my_sinc(t, wc)

% Function that returns a sinc function for given cut-off

% frequency.

%

Page 21: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 21

% Inputs:

% t: Time values (example: -1/50:0.001:1/50)

% wc: Cut-off frequency (example: pi/10)

%

% Outputs:

% x: Sinc signal

<Your code goes here>

end

Submit: Your my sinc function.

(c) (5 points) We will now see that even if our sampling frequency is higher thanthe Nyquist rate, we may not get a perfect reconstruction because the low passfilter h(t) is non-ideal.

We can generate the sinc function of different truncations using the code below:

Tsc = 1/880; % after convolution, the time interval is Tsc

N = 2; % time length

t_intp = - N*Ts : Tsc : N*Ts;

wc = pi/Ts; % cut-off frequency

sinc_intp = Ts * my_sinc(t_intp, wc)

The function sincInterp(xp,sinc intp,Ts,Tsc) outputs the reconstructed sig-nal by interpolating the sampled signal with sinc intp. Sample x(t) with Ts = 1

55

seconds. Plot the reconstructed signal xr(t), the output of sincInterp, for threedifferent truncation lengths N = 1,2,5.

Answer: For each N , does the signal xr(t) look the same as the original signalx(t)? Explain why your answer is reasonable. (Hint: Plot sinc intp and xr(t)in the frequency domain.)

Submit: Plots of xr(t) for the three values of N.

Solution:

(a) For Ts = 1/80. The signal looks the same as the original signal. There are 2spikes at frequency 10 and 25 Hz (or 20π and 50π)For Ts = 1/50. The signal looks the same as the original signal. The magnitudein the frequency domain is different. There are 2 spikes at frequency 10 and 25Hz.For Ts = 1/40. The signal looks different from the original signal. There are 2spikes at frequency 10 and 15 Hz. Aliasing happens.

Page 22: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

22 Homework 11 Solutions

Page 23: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 23

Page 24: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

24 Homework 11 Solutions

(b) function x = my_sinc(t, wc)

x = sin(wc*t)./(pi * t);

x(isnan(x)) = wc / pi;

end

(c) N = 5 gives the best reconstruction result. We can see that for a shorter sinc -

intp, the transition band is wider in the frequency domain, leaking other fre-quency components in the reconstruction results.

Page 25: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 25

Page 26: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

26 Homework 11 Solutions

Code:

set(0,'defaultaxesfontsize',12)

set(0,'DefaultAxesXGrid','on')

set(0,'DefaultLineLineWidth',2)

%% Plot the original continuous signal

Tsc = 1/880;

tsc = -1:Tsc:1-Tsc;

x = cos(20 * pi * tsc)+cos(50 * pi * tsc);

figure

plot(tsc,x);title('The original signal')

xlabel('Time');ylabel('x')

%%

% first Ts = 80 1/80,2 spike at 10 and 25

% then Ts = 40, 1/40, 2 spike at 10 and 15

% then Ts = 50, 1/50, 2 spike at 10 and 25

Ts = 1/55;

ts = -1:Ts:1-Ts;

figure;xp = cos(20 * pi * ts)+cos(50 * pi * ts);

subplot(2, 1, 1);plot(ts, xp);title('sampled signal');xlabel('t');ylabel('x_p')

subplot(2, 1, 2);disFreq(xp,1/Ts)

%% get the sinc function for interpolation

% get different length of sinc function

Page 27: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

Homework 11 Solutions 27

N = 5; % time length

t_intp = - N*Ts : Tsc : N*Ts;

wc = pi/Ts;

% get the sinc functiona

sinc_intp = Ts * my_sinc(t_intp,wc);

xr = sincInterp(xp,sinc_intp,Ts,Tsc);

figure;plot(xr,'Linewidth',1)

title(['Reconstruction with N = ',int2str(N)])

xlabel('Time');ylabel('xr')

figure;disFreq(xr,1/Tsc);xlabel('Frequency');ylabel('Magnitude')

Page 28: Homework 11 Solutions - ece.cmu.eduece290/f17/solutions/hw11-solutions.pdf · Homework 11 Solutions 5 3. (14 points) Consider the continuous-time sinusoid, x(t) = cos(20ˇt)+cos(50ˇt).

28 Homework 11 Solutions

Common Mistakes