Homework 5 Solutions

Similar documents
Homework 5 Solutions

Homework 6 Solutions

Signals and Systems Profs. Byron Yu and Pulkit Grover Fall Midterm 2 Solutions

Homework 9 Solutions

ECE-314 Fall 2012 Review Questions for Midterm Examination II

Homework 3 Solutions

Signals and Systems. Problem Set: The z-transform and DT Fourier Transform

Lab 4: Quantization, Oversampling, and Noise Shaping

Homework 3 Solutions

Homework 1 Solutions

GEORGIA INSTITUTE OF TECHNOLOGY SCHOOL of ELECTRICAL & COMPUTER ENGINEERING FINAL EXAM. COURSE: ECE 3084A (Prof. Michaels)

Digital Signal Processing Lecture 3 - Discrete-Time Systems

Final Exam of ECE301, Section 3 (CRN ) 8 10am, Wednesday, December 13, 2017, Hiler Thtr.

The Johns Hopkins University Department of Electrical and Computer Engineering Introduction to Linear Systems Fall 2002.

Final Exam of ECE301, Prof. Wang s section 1 3pm Tuesday, December 11, 2012, Lily 1105.

x(t) = t[u(t 1) u(t 2)] + 1[u(t 2) u(t 3)]

Grades will be determined by the correctness of your answers (explanations are not required).

ECE 301 Division 1 Exam 1 Solutions, 10/6/2011, 8-9:45pm in ME 1061.

E2.5 Signals & Linear Systems. Tutorial Sheet 1 Introduction to Signals & Systems (Lectures 1 & 2)

New Mexico State University Klipsch School of Electrical Engineering EE312 - Signals and Systems I Fall 2015 Final Exam

Discrete-Time Signals and Systems. Frequency Domain Analysis of LTI Systems. The Frequency Response Function. The Frequency Response Function

Signals and Systems Profs. Byron Yu and Pulkit Grover Fall Midterm 1 Solutions

E : Lecture 1 Introduction

New Mexico State University Klipsch School of Electrical Engineering. EE312 - Signals and Systems I Spring 2018 Exam #1

Digital Signal Processing. Midterm 1 Solution

EE 210. Signals and Systems Solutions of homework 2

Final Exam of ECE301, Section 1 (Prof. Chih-Chun Wang) 1 3pm, Friday, December 13, 2016, EE 129.

ECE 301 Fall 2011 Division 1 Homework 5 Solutions

NAME: ht () 1 2π. Hj0 ( ) dω Find the value of BW for the system having the following impulse response.

EC Signals and Systems

Homework 4. May An LTI system has an input, x(t) and output y(t) related through the equation y(t) = t e (t t ) x(t 2)dt

Final Exam of ECE301, Prof. Wang s section 8 10am Tuesday, May 6, 2014, EE 129.

Analog vs. discrete signals

Frequency-Domain C/S of LTI Systems

Discrete Time Signals and Systems Time-frequency Analysis. Gloria Menegaz

Convolution. Define a mathematical operation on discrete-time signals called convolution, represented by *. Given two discrete-time signals x 1, x 2,

LTI Systems (Continuous & Discrete) - Basics

Chap 2. Discrete-Time Signals and Systems

Chapter 5 Frequency Domain Analysis of Systems

LAB 6: FIR Filter Design Summer 2011

Grades will be determined by the correctness of your answers (explanations are not required).

EE 3054: Signals, Systems, and Transforms Summer It is observed of some continuous-time LTI system that the input signal.

Using MATLAB with the Convolution Method

Overview of Discrete-Time Fourier Transform Topics Handy Equations Handy Limits Orthogonality Defined orthogonal

Outline. Convolution. Filtering

Universiti Malaysia Perlis EKT430: DIGITAL SIGNAL PROCESSING LAB ASSIGNMENT 3: DISCRETE TIME SYSTEM IN TIME DOMAIN

ECE 301 Division 1, Fall 2006 Instructor: Mimi Boutin Final Examination

Interconnection of LTI Systems

EE 224 Signals and Systems I Review 1/10

NAME: 23 February 2017 EE301 Signals and Systems Exam 1 Cover Sheet

Question Paper Code : AEC11T02

Problem Value

Like bilateral Laplace transforms, ROC must be used to determine a unique inverse z-transform.

Fourier series for continuous and discrete time signals

Solutions: Homework Set # 5

Lecture 8 Finite Impulse Response Filters

Aspects of Continuous- and Discrete-Time Signals and Systems

Review of Fundamentals of Digital Signal Processing

LAB 2: DTFT, DFT, and DFT Spectral Analysis Summer 2011

Chapter 3 Convolution Representation

Your solutions for time-domain waveforms should all be expressed as real-valued functions.

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

Review of Fundamentals of Digital Signal Processing

EEL3135: Homework #4

DIGITAL SIGNAL PROCESSING LABORATORY

New Mexico State University Klipsch School of Electrical Engineering. EE312 - Signals and Systems I Fall 2017 Exam #1

The Convolution Sum for Discrete-Time LTI Systems

ELEN 4810 Midterm Exam

LECTURE 12 Sections Introduction to the Fourier series of periodic signals

ECE 301. Division 2, Fall 2006 Instructor: Mimi Boutin Midterm Examination 3

Signals and Systems Spring 2004 Lecture #9

University Question Paper Solution

COMP344 Digital Image Processing Fall 2007 Final Examination

Lecture 11 FIR Filters

Core Concepts Review. Orthogonality of Complex Sinusoids Consider two (possibly non-harmonic) complex sinusoids

Review of Discrete-Time System

ECE538 Final Exam Fall 2017 Digital Signal Processing I 14 December Cover Sheet

Discrete-time Fourier transform (DTFT) representation of DT aperiodic signals Section The (DT) Fourier transform (or spectrum) of x[n] is

ECE 413 Digital Signal Processing Midterm Exam, Spring Instructions:

EECS 20N: Midterm 2 Solutions

ECE 301 Fall 2010 Division 2 Homework 10 Solutions. { 1, if 2n t < 2n + 1, for any integer n, x(t) = 0, if 2n 1 t < 2n, for any integer n.

Problem Value

Complex symmetry Signals and Systems Fall 2015

Solutions - Homework # 3

Overview of Sampling Topics

ESE 531: Digital Signal Processing

2 Background: Fourier Series Analysis and Synthesis

Professor Fearing EECS120/Problem Set 2 v 1.01 Fall 2016 Due at 4 pm, Fri. Sep. 9 in HW box under stairs (1st floor Cory) Reading: O&W Ch 1, Ch2.

EE-210. Signals and Systems Homework 7 Solutions

Fourier Methods in Digital Signal Processing Final Exam ME 579, Spring 2015 NAME

Exercises in Digital Signal Processing

Cosc 3451 Signals and Systems. What is a system? Systems Terminology and Properties of Systems

Each problem is worth 25 points, and you may solve the problems in any order.

Multidimensional digital signal processing

Discrete-Time Fourier Transform (DTFT)

Quiz. Good luck! Signals & Systems ( ) Number of Problems: 19. Number of Points: 19. Permitted aids:

Signals & Systems interaction in the Time Domain. (Systems will be LTI from now on unless otherwise stated)

NAME: 11 December 2013 Digital Signal Processing I Final Exam Fall Cover Sheet

Lecture 8: Signal Reconstruction, DT vs CT Processing. 8.1 Reconstruction of a Band-limited Signal from its Samples

Discrete Time Systems

Transcription:

18-290 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 2017 Homework 5 Solutions Part One 1. (18 points) For each of the following impulse responses, determine whether the corresponding LTI system is (i) stable, (ii) causal, and (iii) memoryless. Justify your answers. (a) h[n] = ( 1) n δ[n] (b) h(t) = e t u(1 t) (c) h[n] = δ[n 2k] k=0 (d) h(t) = sin( π t)u(t + 1) 2 Solution: (a) (b) (c) (d) i. Stable. n= h[n] = 1. ii. Causal. n < 0 h[n] = 0. iii. Memoryless. h[n] = δ[n]. i. Stable. h(t) dt = 1 et dt = e. ii. Not causal. h( 1) = 1 e. iii. Not memoryless. h(t) is not of the form cδ(t). i. Not stable. h[n] is 1 for all non-negative even values of n, so ii. Causal. n < 0 h[n] = 0. iii. Not memoryless. h[n] is not of the form cδ[n]. i. Not stable. h(t) dt = 1 sin( π 2 t) dt =. ii. Not causal. h( 1) = 1. iii. Not memoryless. h(t) is not of the form cδ(t). n= h[n] =.

2 Homework 5 Solutions 2. (16 points) Evaluate and plot the step response for the LTI system represented by each the following impulse responses: (a) h[n] = u[n + 1] u[n 1] (b) h(t) = e t Solution: (a) s[n] = n h[k] = n k= k= i. Case 1: n < 1 s[n] = 0. ii. Case 2: 1 n < 1 s[n] = iii. Case 3: n 1 s[n] = 2. u[k + 1] u[k 1] n k= 1 1 = n + 2. s[n] 4 3 2 1 4 3 2 1 1 2 3 4 1 2 n (b) s(t) = t h(τ)dτ = t e τ dτ i. Case 1: t < 0 s(t) = t eτ dτ = e t ii. Case 2: t 0 s(t) = 0 eτ dτ + t 0 e τ dτ = 2 e t

Homework 5 Solutions 3 s(t) 2 1 4 3 2 1 1 2 3 4 t 1

4 Homework 5 Solutions 3. (10 points) Let h 1 [n], h 2 [n], h 3 [n], h 4 [n] and h 5 [n] be impulse responses of LTI systems. Evaluate the effective impulse response of the following systems: (a) h 4 [n] x[n] h 1 [n] h 2 [n] + h 5 [n] + y[n] h 3 [n] (b) x[n] h 1 [n] h 2 [n] + h 5 [n] + y[n] h 3 [n] h 4 [n] Solution: (a) h[n] = h 1 [n] (h 4 [n] + (h 2 [n] + h 3 [n]) h 5 [n]) (b) h[n] = h 1 [n] ( (h 2 [n] + h 3 [n]) h 5 [n] + h 3 [n] h 4 [n] )

Homework 5 Solutions 5 4. (10 points, vishwa) Let h 1 [n], h 2 [n], h 3 [n], h 4 [n] and h 5 [n] be impulse responses of LTI systems. Draw an interconnected system for each of the following impulse responses: (a) h[n] = (h 1 [n] h 2 [n] + h 3 [n] h 4 [n]) h 5 [n] (b) h[n] = h 1 [n] h 2 [n] + h 3 [n] + h 4 [n] h 5 [n] Solution: (a) x[n] h 1 [n] h 2 [n] + h 5 [n] y[n] h 3 [n] h 4 [n] (b) h 1 [n] h 2 [n] x[n] h 3 [n] + y[n] h 4 [n] h 5 [n]

6 Homework 5 Solutions 5. (20 points) (a) Find the frequency response H(e jω ) of the discrete-time LTI system whose impulse response is h[n] = 1 u[n]. Plot the magnitude response H(e jω ) and phase 2 n response H(e jω ). (b) Find the frequency response H(jω) of the continuous-time LTI system whose impulse response is h(t) = u(t) u(t 1). Plot the magnitude response H(jω) and phase response H(jω). Solution: (a) Let us compute the frequency response of the signal. Thus, H(e jω ) = = k= 1 1 1 2e jω = = 1 1 2e jω h[k]e jωk = 5 ejω +e jω 4 2 H(e jω ) 2 = 1 1 1 2e jω = 1 2 k u[k]e jωk = k= ( 1 1 ) 2e jω 1 1 2e jω (4 2 cos Ω) 2j sin Ω 5 4 cos Ω k=0 ( ) 2 ( ) 2 4 2 cos Ω 2 sin Ω + 5 4 cos Ω 5 4 cos Ω = 16 + 4 cos2 (Ω) 16 cos Ω + 4 sin 2 (Ω) (5 4 cos Ω) 2 4 = (5 4 cos Ω) Or, H(e jω ) = 2 5 4 cos Ω. And H(e jω ) = arctan 2 sin Ω. 4 2 cos Ω 1 (2e jω ) k H(e jω ) 2 H(e jω ) 1 1 π 0 Ω π π 0 Ω π 1

Homework 5 Solutions 7 (b) Let us compute the frequency response of the signal. Thus, H(jω) = [ e jωt = jω h(t)e jωt dt = ] t=1 t=0 1 0 = e jω 1 jω = j (cos(ω) j sin(ω) 1) ω = sin(ω) ω + j cos(ω) 1 ω e jωt dt = j ω (e jω 1) ( ) 2 ( ) 2 sin(ω) cos(ω) 1 H(jω) 2 = + = sin2 (ω) + cos 2 (ω) 2 cos(ω) + 1 ω ω ω 2 = 2(1 cos(ω)) ω 2 = 4 sin2 (ω/2) ω 2 Or, H(jω) = 2 sin(ω/2) and H(jω) = arctan cos(ω) 1. ω sin(ω) H(jω) 2 H(e jω ) 2 1 1 0 ω 4π 3π 2π π π 2π 3π 4π 1 0 ω 4π 3π 2π π π 2π 3π 4π 2

8 Homework 5 Solutions Part Two 6. (12 points) In this problem, we will use convolution to deconstruct and approximately reconstruct a signal in MATLAB. Please download hw5 matlab.zip from Canvas or the course website (http://ece.cmu.edu/~ece290/f17/homeworks/hw5_ matlab.zip). Unzip it in your working directory, and you will find two files hw5 q1.mat and view frequencies.m. hw5 q1.mat contains a signal, called sig, as well as the impulse response of 3 filters IR1,IR2 and IR3 to process the signal with. Also included in hw5 q1.mat is the parameter fs, which is the sampling frequency of sig and is equal to 44,100 (sig is a sound signal recorded at a sampling frequency of at 44.1 khz). view frequencies.m takes in an impulse response and the sampling frequency, and outputs the frequency response. The built-in MATLAB function sound(signal, fs) will play back the sound signal. (a) Observe the frequency response of the three filters using view frequencies.m using the code below. Submit: Which one is a low-pass filter, high-pass filter and band-pass filter? (No plots or code submission needed.) clear all load (' hw5_q1. mat ') % load data into the workspace % Plot one impluse response as an example [f,amp ] = view_frequencies (IR1,fs ); plot (f,amp,' Linewidth ',2) title (' Frequency response of IR1 ') xlabel ('f(hz )') ylabel (' H(f) ') (b) Convolve each of the three impulse responses separately with the signal sig. Listen to sig and listen to each of the filtered outputs. Submit: Your code. And based only on what you hear, describe how does the sound of each of the 3 filtered outputs differ from that of sig in 1 to 2 sentences. (c) view frequencies(sig,fs) can also examine the frequency components contained in a signal, sig. Generally speaking, songs of David Bowie contain more low frequency components than Maroon 5 songs. So from what you hear in Problem 6b, you should have an expectation of what kinds of frequency components are contained in each filtered output. Now, let us verify that. Plot the frequency components of sig, as well as that of the 3 filtered outputs using view frequencies(sig,fs). Submit: The 4 plots with appropriate labels and your code. Since you know the type of filter corresponding to each impulse response in Problem 6a, label the

Homework 5 Solutions 9 plots as Convolution with Low Pass, etc. Do not use labels such as Convolution with IR1,etc. Explain how each filter modifies the frequency components of sig. (d) We separated the signal into three components, i.e, we deconstructed it into 3 bands based on frequency: low, middle, and high frequencies. Now, let us see what happens if we put the 3 components back together. Add the three convolved signals together, plot the signal, and listen to the output. Submit: The plots of the original signal and the reconstructed signal. Do the plots look exactly the same? Do the signals sound similar or different? Solution: (a) IR1 is high pass, IR2 is low pass and IR3 is band pass. (b) The three filters cause the output to only have low, medium, and high frequencies. The code is in part (c) (c) Students should see what they heard in part (b); that only certain frequencies are retained after each filtering operation (the same frequencies present in the filters themselves). Frequencies not present in the filter s frequency response do not appear in the output when the original sound signal is passed through. % view the frequency components of the original signal [f,amp ] = view_frequencies (sig,fs ); figure ; plot (f,amp,' Linewidth ',2) title (' The original signal ') xlabel ('f(hz )') ylabel (' X(f) ') % view the filtered signal high_r = conv (sig, IR1 ); % change the second input to IR2, IR3 for other filters soundsc ( high_r,fs) [f,amp ] = view_frequencies ( high_r,fs ); figure ; plot (f,amp,' Linewidth ',2) title (' Convolution with high pass ') xlabel ('f(hz )') ylabel (' X(f) ')

10 Homework 5 Solutions

Homework 5 Solutions 11 (d) The reconstructed signal should sound similar to the original, but may have a tinny sound to it. They will observe that the reconstructed signal once again has low and high pitches/frequencies. recover_sig = band_r + low_r + high_r ; soundsc ( recover_sig,fs)

12 Homework 5 Solutions plot ( sig ) title (' The original signal ') figure plot ( recover_sig (501:1000500)) title (' The recovered signal ')

Homework 5 Solutions 13 7. (13 points) Convolutions are also defined for 2D signals, such as grayscale images. In this problem we will explore image filtering based on 2D convolutions. Consider a grayscale image I(x, y), which is a discrete 2D signal, and a discrete 2D impulse response h(x, y). A discrete 2D convolution is defined as: J(x, y) = W U w= W u= U I(x u, y w)h(u, w) The impulse response h is defined on the 2D interval { U u U, W w W }, which is represented in a matrix of size (2U + 1) (2W + 1). (a) (4 points) Gaussian blur impulse response We will experiment with the Gaussian blur impulse response. In the 1D case, the Gaussian impulse response smooths out the signal and has the following form h(t) = e t2 2σ 2, where σ controls the degree of smoothing. In 2D, we can smooth in both directions. If we smooth the same amount in all directions, the impulse response will have the following expression: h(u, w) = e ( u2 +w 2 2σ 2 ) Our impulse response has a finite size of (2U + 1) (2W + 1) since it is easier to implement in Matlab. Below is the function to build a symmetric 2D Guassian impulse response for a given size and given σ. function h = gaussian2d ( sigma, U, W) %% GAUSSIAN2D generates a symmetric normalized 2 D Gauss. % of size is [2* U +1 x 2* W +1] h = zeros (2* W+1, 2*U +1); for y = 1 : 2* W +1 for x = 1 : 2* U + 1 w = y - W - 1; u = x - U - 1; h(y, x) = exp (-(w^2 + u ^2) /(2* sigma ^2)); end end Using this function, generate three impulse responses for three combinations of parameters (σ, U, W ) = (1, 5, 5), (5, 5, 5), and (5, 10, 10). Plot each of them using Matlab s function surf(h), and submit the three resulting plots. (b) (2 points) Normalization Our impulse response has to be normalized so that its values sum up to one. Change the function gaussian2d appropriately. The result should satisfy:

14 Homework 5 Solutions h = gaussian2d ( sigma, U, W); assert ( sum (h (:)) == 1); % summing up all the values Submit the new function. Also explain why this normalization is necessary for image blur. (c) (4 points) Convolution We will run experiments on saturn.png image, which is built in to Matlab. Load it and transform the image to grayscale: I = I = imread (' saturn.png '); rgb2gray (I); To display the image in a figure, use Matlab command imshow: imshow (I); Instead of implementing our own 2D convolution function, we will use Matlab function conv2 for this exercise. Just like with 1D convolution, we always need to pay attention to the boundary conditions, i.e. how to treat pixels near image edges. Matlab offers several different options. In this exercise we will use the one named same, which does not change the size of the input image: I = double (I); I2 = conv2 (I, h, 'same '); imshow ( uint8 (I2 )); Create two impulse responses with different values of σ, i.e (σ, U, W ) = (3, 9, 9) and (10, 30, 30). Use conv2 to blur the saturn image and submit two output blurred images. You can use function imwrite(uint8(i2), filepath ) to save an image. Function uint8 transforms floating point values into integers in range [0, 255]. Does the level of blurring increase or decrease with higher values of σ? (d) (3 points) Directional blur Instead of blurring uniformly, we can perform a directional blur. To blur an image in the X-direction, we need to create an impulse response, such that its values change only in the X-direction. Fortunately, we can accomplish this without making any changes to the gaussian2d function! The following code generates an impulse response with σ= 10. Note that W is set to 0, which means the impulse response is of size (2U + 1) 1. That is, the impulse response only exists along the X-direction. h_x = gaussian2d (10, 30, 0);

Homework 5 Solutions 15 Perform convolution of the saturn image with h x and submit the blurred image. How can you tell the result is blurred only along the X-direction? Solution: (a) Three figures shown below:

16 Homework 5 Solutions (b) The blur must have no effect if applied to a one-colored gray image because there is nothing to blur. Let image intensity be I 0. Then convolution operation applied at every pixel can be written as: W U w= W u= U I(x u, y w)h(u, w) = W U w= W u= U W U w= W u= U h(u, w) = 1 I 0 h(u, w) = I 0 function h = gaussian2d ( sigma, U, W) %% GAUSSIAN2D generates a symmetric normalized 2 D Gauss. % of size is X x Y = [2* U +1 x 2* W +1] h = zeros (2* W+1, 2*U +1); for y = 1 : 2* W +1 for x = 1 : 2* U + 1 w = y - W - 1; u = x - U - 1; h(y, x) = exp (-(w^2 + u ^2) /(2* sigma ^2)); end end h = h / sum (h (:));

Homework 5 Solutions 17 (c) As σ increases, blurring increases. (3, 9, 9) (10, 30, 30)

18 Homework 5 Solutions (d) One can notice that Saturns moons are blurred only in the X-direction.

Homework 5 Solutions 19

Time Taken 20 Homework 5 Solutions Common Mistakes Problem 5 Wrong label axes: instead of expressing an angle in pi or or other scale, labeled with simple numbers (1,2,3.) (I didnt penalize though). For part (b) the phase plot was wrong for everyone.