8-290 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 207 Homework 9 Solutions Part One. (6 points) Compute the convolution of the following continuous-time aperiodic signals. (Hint: Use the convolution property of the Fourier representations) x (t) = sin( 3πt) 4 πt ( sin( π 7 x 2 (t) = t) πt Solution: According to the convolution property, we have From the table we get ) 2 x (t) x 2 (t) X (j)x 2 (j) X (j) = { 3π 4 0 otherwise X (j) 3π 4 3π 4 For X 2 (j), we can first find the F of x 3 (t) = sin( π 7 t) πt property. and then use the multiplication
2 Homework 9 Solutions X 3 (j) = { π 7 0 otherwise X 3 (j) π 7 π 7 Calculate X 2 (j) = 2π X 3(j) X 3 (j) we get + 2π 0 2π 7 7 X 2 (j) = 2π + 0 < 2π 7 7 0 otherwise X 2 (j) 7 2π 7 2π 7 Since 2π < and 2π < 3π, we have X 7 7 4 (j)x 2 (j) = X 2 (j) hus x (t) x 2 (t) = x 2 (t) = ( sin( π 7 t) ) 2 πt
Homework 9 Solutions 3 2. (0 points) Determine whether the time-domain signals corresponding to the following frequency-domain representations are real, purely imaginary, or neither. Also determine whether the time-domain signals are even, odd or neither. Briefly explain your answer by identifying the relevant features of the frequency-domain representations. (a) F X(j) is given as below. X(j) X(j) π 2 5 4 3 2 2 3 4 5 2 4 5 4 3 2 3 5 π 2 (b) One period of DFS X[k] is given as below. X[k] X[k] π 5 4 3 2 2 3 4 5 k 5 4 3 2 2 3 4 5 k π Solution: (a) Based on the given information, we know Re{X(j)} = 0 and X(j) is odd. As a result x(t) is real and odd. (b) Based on the given information, we know Im{X[k]} = 0 and X[k] is even. As a result x[n] is real and even.
4 Homework 9 Solutions 3. (2 points) Let x (t) = u(t + ) u(t ) and y (t) = x (t) x (t) be the continuoustime convolution of x (t) with itself. (a) Evaluate X (j), the F of x (t). (b) Evaluate Y (j), the F of y (t). (c) Evaluate Y (j), the F of y(t) given below. (Hint: Express y(t) as a sum of x (t) and y (t)) y(t) 3 2 2 2 t Solution: (a) X (j) = x (t)e jt dt = = t= t= t= (u(t + ) u(t ))e jt dt e jt dt = e jt j = ej e j j = 2 sin()
Homework 9 Solutions 5 (b) y (t) = x (t) x (t). By the convolution property of Fourier ransform, we have, Y (j) = X (j)x (j) ( ) ( ) 2 sin() 2 sin() = ( ) 2 2 sin() = (c) Notice that y(t) = x (t) + y (t). Using linearity of F, we have, Y (j) = X (j) + Y (j) ( ) ( 2 sin() 2 sin() = + ) 2
6 Homework 9 Solutions 4. (0 points) Given the continuous-time signal x(t) = sin(πt), compute the F for the πt following signals. (a) y (t) = t x(τ + 2)dτ (b) y 2 (t) = d2 dt 2 x(t) d dt x(t) Solution: x(t) = sin(πt) πt X(j) = {, π 0, otherwise (a) y (t) = t x(τ + 2)dτ let s do a variable change σ = τ + 2 = y (t) = t+2 x(σ)dσ = y (t + 2) t x(σ)dσ = Y (j) = X(j) + πδ() j y (t) = y (t + 2) = Y (j) = e j2 Y (j) his implies: y (t) = t x(τ + 2)dτ Y (j) = e j2 Y (j) ( ) Y (j) = e j2 X(j) + πδ() j Y (j) = ej2 j X(j) + ej2 πδ() y (t) = t x(τ + 2)dτ Y (j) = { e j2 j + ej2 πδ(), π 0, otherwise
Homework 9 Solutions 7 (b) his implies the following: y 2 (t) = d2 dt 2 x(t) d dt x(t) y 2 (t) = d2 dt 2 x(t) = Y 2(j) = (j) 2 X(j) = Y 2 (j) = 2 X(j) y 22 (t) = d dt x(t) = Y 22(j) = jx(j) y 2 (t) = d2 dt 2 x(t) d dt x(t) Y 2(j) = 2 X(j) jx(j) Y 2 (j) = ( 2 j)x(j) { ( 2 j), π Y 2 (j) = 0, otherwise
8 Homework 9 Solutions 5. (8 points) Determine the time-domain signals for the following Fourier representations. (a) Y (e jω ) = j d dω X(ejΩ ) X(e jω ), where X(e jω ) = 5 e jω (b) Y 2 (j) = j d (X(j( + 2π)) + X(j( 2π))), where X(j) = d 5+j Solution: (a) ( ) n X(e jω ) = x[n] = u[n] e jω 5 5 X (e jω ) = j d dω X(ejΩ ) x [n] = nx[n] (b) his implies that y[n] = nx[n] x[n] = (n )x[n] ( ) n = (n ) u[n] 5 X(j( + 2π)) x(t)e j2πt X(j( 2π)) x(t)e j2πt X(j( + 2π)) + X(j( 2π)) x(t)e j2πt + x(t)e j2πt x(t) ( e j2πt + e j2πt) 2x(t) cos(2πt) j d (X(j( + 2π)) + X(j( 2π))) 2tx(t) cos(2πt) d X(j) = 5 + j x(t) = e 5t u(t) Y 2 (j) y 2 (t) = 2te 5t u(t) cos(2πt)
Homework 9 Solutions 9 Part wo 6. (6 points) Consider the signal x(t) = 0 = 0π. (a) Sketch the Fourier transform X(j). ( πt sin( ) πt ) 2. Let xc (t) = cos( 0 t), where (b) Now x(t) is input to a system H which multiplies it with x c (t), giving y (t). Sketch the Fourier transform Y (j). (c) he output y (t) is further input to the same system, which gives, y 2 (t) = y (t)x c (t). Sketch the Fourier transform Y 2 (j). (d) Now consider the system whose frequency response is H(j) = u( + 2π) u( 2π ). Evaluate the signal y 3(t) = y 2 (t) h(t), where h(t) is the impulse response of the system. Is y 3 (t) related to x(t)? ) πt sin( 2, Solution: x(t) = ( ) xc (t) = cos( 0 t) πt (a) Observe that x(t) = ( sinc( t )) 2. he Fourier transform for x(t) = sinc( t ) is X(j) = ( u( + π ) u( π )) Using the property that multiplication in time domain is convolution in frequency domain, we have, X(j) = 2π ( X(j) X(j)) = ( 2π u( + π ) u( π ) ) { ( + 2π = ), 2π < 0 ( ), 0 < 2π 2π X(j) (u( + π ) u( π ) ) 2π 2π
0 Homework 9 Solutions (b) y (t) = x(t)x c (t) Using the property that multiplication in time domain is convolution in frequency domain, we have, Y (j) = X(j) X c (j) x c (t) = cos( 0 t) = X c (j) = π(δ( + 0 ) + δ( 0 )) Hence, Y (j) = 2π X(j) π(δ( + 0) + δ( 0 )) = 2 (X(j( 0)) + X(j( + 0 ))) 2 Y (j) 4 2π 0 0 2π 0 0 0 2π + 0 0 2π + 0 (c) y 2 (t) = y (t)x c (t). Using the property of time domain multiplication again, Y 2 (j) = 2π Y (j) π(δ( + 0 ) + δ( 0 )) = 2 (Y (j( 0 )) + Y (j( + 0 ))) ( = 4 (X(j( 0 0 )) + X(j( 0 + 0 ))+ X(j( + 0 0 )) + X(j( + 0 + 0 ))) = 4 (X(j( + 2 0)) + 2X(j) + X(j 2 0 )) 2 Y (j) 4 2π 2 0 2 0 2π 2 0 2π 0 0 2π 2π +2 0 2 0 2π +2 0
Homework 9 Solutions (d) y 3 (t) = y 2 (t) h(t). Using the property that time domain convolution is frequency domain multiplication, we have, Y 3 (j) = Y 2 (j)h(j) = 4 (X(j( + 2 0)) + 2X(j) + X(j 2 0 ))H(j) Now, notice that H(j) 0, 2π X(j) 0, 2π 2π. Similarly, X(j( + 2 0 )) 0, 2π X(j( 2 0 )) 0, 2π Given that 0, X(j( ± 2 0 ))H(j) = 0. Hence, 2π. Further, 2 0 2π 2 0 + 2 0 2π + 2 0 Y 3 (j) = 4 2X(j)H(j) = 2 X(j) his problem describes the concept of amplitude modulation. Notice that the original signal, x(t) is a low frequency signal. In practice, low frequency signals not only require very large antennae, but also get mixed up when sent in air. his problem is circumvented by shifting the signal to higher frequency by multiplying it with a very high frequency cosine signal, x c (t), called a carrier signal. he recovery of the signal is an easy operation, which involves multiplication with the same carrier signal x c (t) and cutting off the high frequency terms.
2 Homework 9 Solutions 7. (7 points) Consider the discrete-time periodic signal x[n] = sin ( π 3 n) + sin ( π 5 n). (a) (2 points) Evaluate Ω 0, the fundamental frequency of x[n]. (b) (3 points) Compute the DFS coefficients with Ω 0 as the fundamental frequency. (c) (3 points) Compute the DFS coefficients with fundamental frequency Ω 0 /5. (Hint: his is simply a change of index in the DFS.) Solution: (a) Let x (t) = sin ( π 3 n) and x 2 (t) = sin ( π 5 n) Ω = 2π π 3 = 6 Ω 2 = 2π π 5 = 0 = Ω 0 = LCM(6, 0) = 30. (b) ( π ) x[n] = sin 3 n = 2j = 2j ( π ) + sin 5 n ( ) e j π 3 n e j π 3 n + ( e j π 5 n e j π n) 5 2j ( ) e j 5 2π 30 n e j 5 2π n 30 + ( ) e j 3 2π 30 n 3 2π j e 30 n 2j = X[ 5] = 2j X[ 3] = 2j X[3] = 2j X[5] = 2j
Homework 9 Solutions 3 (c) x[n] = 2j = 2j ( ) e j π 3 n e j π 3 n + ( e j π 5 n e j π n) 5 2j ( ) e j 25 2π 50 n e j 25 2π n 50 + ( ) e j 5 2π 50 n 5 2π j e 50 n 2j = X[ 25] = 2j X[ 5] = 2j X[5] = 2j X[25] = 2j
4 Homework 9 Solutions 8. (5 points) Extra files: Download the files required Matlab questions from Canvas or course website, http://ece.cmu.edu/~ece290/homeworks/hw9_matlab.zip. Unzip it in your working directory, and you will find the files g.png, MatlabQ9.m, and dtfs.m. (a) (6 points) he purpose of this problem is to visually illustrate the convolution property of Fourier transform. You will use the following discrete-time periodic signals: ( ) 2π f[n] = sin where N is a constant. 30 n ), ( 2π g[n] = sin N n Derive the DFS coefficients of f[n] using pencil and paper assuming fundamental period, N 0 = 30. Using the convolution property, evaluate the DFS coefficients of h[n] = g[n] f[n] using pencil and paper, where g[n] = sin ( 2π n) for N = 60, N = N 30, and N = 2. (Hint: Use results from Problem 7) Evaluate the discrete-time signal h[n] for the three values of N using pencil and paper. Submit: DFS of f[n], DFS of h[n], and h[n] for the three values of N. (b) (5 points) Visualization You will now see what the signal h[n] = g[n] f[n] looks like. First, create an array f, which represents 0 periods of f[n] = sin ( 2π 30 n). n = [:300]; f = sin(2*pi/30*n); Plot f and submit the plot. Now load the image g.png, provided in the zip-file. You can view the image using imshow(g). he image contains three rows, where each row is a sinusoid with periods N = 60, 30 and 2. herefore, each row represents g[n] for one value of N. g = imread('g.png'); g = double(g) - 27.5; % subtract the mean Now that you have the signals f[n] and g[n], you can compute h[n] = g[n] f[n]. o convolve the two signals, you use the function cconv from the Image Processing oolbox of Matlab. It convolves two periodic D signals, and hence each horizontal line of g is going to be convolved with f independently.
Homework 9 Solutions 5 h = zeros(size(g)); % create image h same of size as g for y = : size(h,) % for each horizontal line result = cconv(g(y,:), f, 300); % perform convolution h(y,:) = result; % assign the computed result to h end %% Normalize the image and display. imshow(normalize(h)); Submit: Plot of f and the image of h. (c) (4 points) Interpretation In part (a) you computed the time domain representation of signal h[n] for three values of N using the convolution property of DFS. In part (b) you computed h[n] directly using convolution. Do the results of parts (a) and (b) match? Solution: (a) DFS coefficients for discrete periodic sine function are: x[n] = sin (pω 0 n) 2j δ[k p] δ[k + p] 2j he fundamental period of f equals 30 and Ω = 2π. herefore, p = in the formula above. So the DFS coefficients are: 2j δ[k ] δ[k + ] 2j g[n] f[n] NG[k]F [k], where N is the common period. If N = 60 or N = 2, then If N = 30, then g[n] = h[n], and If N = 60 or N = 2, If N = 30, NG[k]F [k] = 0 NG[k]F [k] = 30G[k] 2 = 30( 2j δ[k ] δ[k + ])2 2j = 5( 2 δ[k ] + δ[k + ]) 2 g[n] h[n] = 0 g[n] h[n] = 5cos( 2π 30 n) that is, h[n] is a harmonic function with the same period N = 30.
6 Homework 9 Solutions (b) Below are the two figures. (c) he top and bottom parts of image h is uniform gray, which means that h[n] = 0 for periods = 60 and = 2. On the other hand, the center part of image h
Homework 9 Solutions 7 is a harmonic function with the period N = 30 as in the center of image g, as predicted in part (a).
8 Homework 9 Solutions 9. (5 points) In this problem, we will study the first difference of discrete-time signals. We need to fill in the missing part of MatlabQ9.m for parts (b),(c), and (e) according to the instructions. (a) (3 points) Create a signal x [n] such that x [n] = cos ( πn ) 20 Now we will take the first difference of x [n], namely x 2 [n] = x [n] x [n ]. Derive the expression of x 2 [n] using pencil and paper. Submit: Expression for x 2 [n]. (b) (3 points) We can compute the first difference in Matlab, using the diff function as follows: x2 = [0 diff(x)]; % extra zero to have same length as x Define x [n] and x 2 [n] in MatlabQ9.m, and plot the frequency domain representations of x [n] and x 2 [n] using dtfs(x,n,k) from Homework 7, where n = -200:99 and k = -200:99. Answer: What is the dominant frequency? What is the amplitude at that frequency? Do the frequency and the amplitude match your pencil and paper calculations? Submit: Code for computing x 2 [n] and DFS of x 2 [n], and the frequency domain plots of x [n] and x 2 [n]. (c) (3 points) Now, let us add noise to x [n] and generate the signal sig as below. sig = x + 0.02 * randn(size(x)); % add noise to the clean signal hen compute sig2, the first difference of sig. Define x [n] and x 2 [n] in MatlabQ9.m and plot the two signals. hen plot the DFS coefficients of sig and sig2 and compare the plots. Answer: What happens to the amplitude of the noise when we take the first difference? Answer this question by compare sig and sig2 in the time domain and the frequency domain. Submit: Code for generating sig and sig2, plots of the two time-domain signals and their DFS coefficients. (d) (3 points) Now let us analyze the result in (c) by looking at the frequency response of the first difference operation. Let X[k] be the DFS coefficients of
Homework 9 Solutions 9 x[n]. Derive Y [k], the DFS of y[n] = x[n] x[n ] using pencil and paper. Find H[k] such that Y [k] = H[k]X[k]. Submit: Expressions for Y [k] and H[k] (e) (3 points) Plot the magnitude of H[k] for k = -200:99 and N = 400 in MatlabQ9.m. Answer: Describe how the plot of H[k] explains your observations in part (c). Submit: Code and plot for H[k]. Solutions: (a) x 2 [n] = cos ( πn 20 ) ( ) cos π(n ) = 2 sin ( π 20 40 ) ( ) sin π(2n ) 40 (b) he dominant frequency is 0.025 Hz and the amplitude of one spike should be sin ( π 40) = 0.0785, which matches with the plot.
20 Homework 9 Solutions (c) For the original signal, the noise is negligible in time domain, and we can see the noise has smaller amplitude than the main frequency. After taking the difference, noise becomes obvious in the time domain and the value relative to the main frequency increases in the frequency domain.
Homework 9 Solutions 2
22 Homework 9 Solutions (d) Y [k] = ( e j 2π N k )X[k] H[k] = e j 2π N k (e) Notice that this is a high pass filter. So the noise is enhanced.(if the x-axis is k instead of frequency, student can also get full points for the plot.) Code: %% question b n = -500:499; k = -500:499; % define x and x2 x = cos(n*pi/20); x2 = [0 diff(x)]; % hen calculate their DFS X = dtfs(x,n,k); X2 = dtfs(x2,n,k);
Homework 9 Solutions 23 % Plot freq = k/000; % convert to real frequencies % plot X figure;stem(freq,real(x),'filled','linewidth',2);grid on title('he original signal');xlabel('frequency(hz)');ylabel('dfs'); % plot X2 figure;stem(freq,imag(x2),'filled','linewidth',2);grid on title('he first difference');xlabel('frequency(hz)');ylabel('dfs'); %% question c sig = x + 0.02 * randn(size(x)); % add noise to the clean signal sig2 = [0 diff(sig)]; % Calculate DFS S = dtfs(sig,n,k); S2 = dtfs(sig2,n,k); % plot sig figure; subplot(,2,);plot(n,sig,'linewidth',.5); title('ime domain');xlabel('n');ylabel('sig') subplot(,2,2);stem(freq,abs(s),'.','linewidth',.5); title('frequency domain');xlabel('frequency(hz)');ylabel('abs(s)') % plot sig2 figure; subplot(,2,);plot(n,sig2,'linewidth',.5); title('ime domain');xlabel('n');ylabel('sig2') subplot(,2,2);stem(freq,abs(s2),'.','linewidth',.5); title('frequency domain');xlabel('frequency(hz)');ylabel('abs(s2)') %% question e H = - exp(i * 2*pi/000*k); stem(freq,abs(h),'.','linewidth',.5) title('frequency response');xlabel('frequency(hz)');ylabel('abs(h)')
24 Homework 9 Solutions Common Mistakes