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

Similar documents
LAB 6: FIR Filter Design Summer 2011

Digital Signal Processing: Signal Transforms

Fast Fourier Transform Discrete-time windowing Discrete Fourier Transform Relationship to DTFT Relationship to DTFS Zero padding

Fast Fourier Transform Discrete-time windowing Discrete Fourier Transform Relationship to DTFT Relationship to DTFS Zero padding

Lecture 10. Digital Signal Processing. Chapter 7. Discrete Fourier transform DFT. Mikael Swartling Nedelko Grbic Bengt Mandersson. rev.

CHAPTER 7. The Discrete Fourier Transform 436

Discrete Fourier Transform

LABORATORY 1 DISCRETE-TIME SIGNALS

Assignment 2. Signal Processing and Speech Communication Lab. Graz University of Technology

Digital Signal Processing. Midterm 2 Solutions

E : Lecture 1 Introduction

EEO 401 Digital Signal Processing Prof. Mark Fowler

Review of Discrete-Time System

DFT-Based FIR Filtering. See Porat s Book: 4.7, 5.6

TTT4120 Digital Signal Processing Suggested Solutions for Problem Set 2

Digital Signal Processing Lecture 10 - Discrete Fourier Transform

/ (2π) X(e jω ) dω. 4. An 8 point sequence is given by x(n) = {2,2,2,2,1,1,1,1}. Compute 8 point DFT of x(n) by

Definition. A signal is a sequence of numbers. sequence is also referred to as being in l 1 (Z), or just in l 1. A sequence {x(n)} satisfying

EE-210. Signals and Systems Homework 7 Solutions

EE482: Digital Signal Processing Applications

Digital Signal Processing Lab 3: Discrete Fourier Transform

HW13 Solutions. Pr (a) The DTFT of c[n] is. C(e jω ) = 0.5 m e jωm e jω + 1

Discrete Fourier transform (DFT)

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

6.003 Signal Processing

! Circular Convolution. " Linear convolution with circular convolution. ! Discrete Fourier Transform. " Linear convolution through circular

! Introduction. ! Discrete Time Signals & Systems. ! Z-Transform. ! Inverse Z-Transform. ! Sampling of Continuous Time Signals

Overview of Sampling Topics

Chapter 4 Discrete Fourier Transform (DFT) And Signal Spectrum

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.

L6: Short-time Fourier analysis and synthesis

DSP Laboratory (EELE 4110) Lab#5 DTFS & DTFT

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

UNIVERSITY OF OSLO. Please make sure that your copy of the problem set is complete before you attempt to answer anything.

Summary of lecture 1. E x = E x =T. X T (e i!t ) which motivates us to define the energy spectrum Φ xx (!) = jx (i!)j 2 Z 1 Z =T. 2 d!

Digital Signal Processing Chapter 10. Fourier Analysis of Discrete- Time Signals and Systems CHI. CES Engineering. Prof. Yasser Mostafa Kadah

EEL3135: Homework #3 Solutions

J. McNames Portland State University ECE 223 Sampling Ver

DISCRETE FOURIER TRANSFORM

The Z-Transform. For a phasor: X(k) = e jωk. We have previously derived: Y = H(z)X

Solutions - Homework # 3

Digital Signal Processing

7.16 Discrete Fourier Transform

Lecture 19: Discrete Fourier Series

In this Lecture. Frequency domain analysis

ECSE 512 Digital Signal Processing I Fall 2010 FINAL EXAMINATION

6.003 Signal Processing

Module 3. Convolution. Aim

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

Discrete Fourier transform (DFT)

Multidimensional digital signal processing

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

1. Calculation of the DFT

Introduction to DFT. Deployment of Telecommunication Infrastructures. Azadeh Faridi DTIC UPF, Spring 2009

VII. Discrete Fourier Transform (DFT) Chapter-8. A. Modulo Arithmetic. (n) N is n modulo N, n is an integer variable.

University of Illinois at Urbana-Champaign ECE 310: Digital Signal Processing

Digital Signal Processing. Midterm 1 Solution

Department of Electrical and Computer Engineering Digital Speech Processing Homework No. 6 Solutions

University of Illinois at Urbana-Champaign ECE 310: Digital Signal Processing

Lecture 13: Discrete Time Fourier Transform (DTFT)

Ch.11 The Discrete-Time Fourier Transform (DTFT)

ENT 315 Medical Signal Processing CHAPTER 2 DISCRETE FOURIER TRANSFORM. Dr. Lim Chee Chin

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

EE123 Digital Signal Processing

Lecture 5. The Digital Fourier Transform. (Based, in part, on The Scientist and Engineer's Guide to Digital Signal Processing by Steven Smith)

INTRODUCTION TO THE DFS AND THE DFT

EEO 401 Digital Signal Processing Prof. Mark Fowler

ESE 531: Digital Signal Processing

DFT Octave Codes (0B) Young Won Lim 4/15/17

Fourier Analysis of Signals Using the DFT

Aspects of Continuous- and Discrete-Time Signals and Systems

Chapter 8 The Discrete Fourier Transform

x[n] = x a (nt ) x a (t)e jωt dt while the discrete time signal x[n] has the discrete-time Fourier transform x[n]e jωn

PROBLEM SET 3. Note: This problem set is a little shorter than usual because we have not covered inverse z-transforms yet.

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

Introduction to DSP Time Domain Representation of Signals and Systems

18.085: Summer 2016 Due: 3 August 2016 (in class) Problem Set 8

Fall 2011, EE123 Digital Signal Processing

LAB # 5 HANDOUT. »»» The N-point DFT is converted into two DFTs each of N/2 points. N = -W N Then, the following formulas must be used. = k=0,...

Centre for Mathematical Sciences HT 2017 Mathematical Statistics

FFT Octave Codes (1B) Young Won Lim 7/6/17

Frequency-domain representation of discrete-time signals

Chirp Transform for FFT

ELEN 4810 Midterm Exam

Discrete Fourier Transform

Computer Engineering 4TL4: Digital Signal Processing

QUIZ #2 SOLUTION Version A

L29: Fourier analysis

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

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

Multimedia Signals and Systems - Audio and Video. Signal, Image, Video Processing Review-Introduction, MP3 and MPEG2

ECE-314 Fall 2012 Review Questions for Midterm Examination II

Problem 1. Suppose we calculate the response of an LTI system to an input signal x(n), using the convolution sum:

Problem Score Total

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EC2314- DIGITAL SIGNAL PROCESSING UNIT I INTRODUCTION PART A

sinc function T=1 sec T=2 sec angle(f(w)) angle(f(w))

Problem Set 8 - Solution

Chap 2. Discrete-Time Signals and Systems

The Discrete Fourier Transform

Voiced Speech. Unvoiced Speech

Transcription:

University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 311: Digital Signal Processing Lab Chandra Radhakrishnan Peter Kairouz LAB 2: DTFT, DFT, and DFT Spectral Analysis Summer 2011 1 Overview In this lab we will perform frequency domain analysis of Discrete-Time signals using MATLAB. The objective of this lab is to teach you how interpret and analyze the frequency spectra of digital signals with fixed frequency contents and others with time varying frequency contents such as speech signals. 2 DTFT The DTFT is used to represent discrete-time signals in terms of complex exponential signals e jωn. The DTFT of a discrete-time signal x[n] is given by, X d (w) = x[n]e jωn, which is called the DTFT analysis equation. The synthesis equation is given by, 1 2π π π X d (ω)e jωn dω Note the DTFT is periodic with period 2π. The two major limitations for any numerical implementation of DTFT are that x[n] must have finite length and X(e jω ) can only be computed at a finite number of samples of the continous frequency variable ω. 3 DFT and IDFT In order to compute the DTFT of a signal x[n] using MATLAB the signal x[n] must be first truncated to form a finite length signal. This is not necessarily a limitation since in real life applications, we only have finite recordings of sampled and quantized (i.e. digitized) continuous time signals. Also, X(e jw ) can be computed only at a discrete set of frequency samples, w k. This is also not necessarily a limitation: if enough samples are chosen, the discrete time signal could be perfectly reconstructed using the inverse DFT (IDFT) synthesis equation. In addition, in the case when enough samples are chosen, the plot of these frequency samples will be a good representation of the actual DTFT. For computational efficiency, the best set of frequency samples is the set of equally spaced points in the interval 0 ω 2π given by ω k = 2πk N for k = 0, 1,..., N 1. For a signal x[n] which is nonzero only for 0 n M 1 the DFT is defined by, X[k] = M 1 n=0 x[n]e j2πkn/n, k = 0, 1,..., N 1 1

The Inverse DFT (IDFT) is given by, N 1 k=0 x[n]e j2πkn/n, n = 0, 1,..., M 1 The function fft implements the DFT operation in a computationally efficient manner. FFT stands for Fast Fourier Transform and will be studied in greater details towards the end of the course. If x is a vector containing x[n] for 0 n M 1 and N M, then X=fft(x,N) computes N evenly spaced samples of the DTFT of x and stores these samples in the vector X. If N < M, then the MATLAB function fft truncates x to its first N samples before computing the DTFT, thus yielding incorrect values for the samples of the DTFT. The function ifft can be used to compute the IDFT efficiently. Also note that the fft function computes the DFT in the interval [0, 2π]. To reorder the samples in the interval [ π, π] you can use the function fftshift. 4 Example Consider the following signal, 1. u[n] u[n 11] What is the DTFT of the Signal? Compute the DFT using the fft function. Plot the magnitude of the spectrum. One can improve the resolution of the DFT by zero padding the input and then computing its DFT. This can be done using the fft(x,n) command by choosing N > M, where M is the sequence length. Choose N = 100, 500, 1000. Does the DFT look similar to the DTFT? 2. A MATLAB code to plot the DFT N = 8; n = 0:(N-1); x = (0.7).^n; k = 0:(N-1); Xdft_8 = fft(x,n); mag_xdft_8 = abs(xdft_8); phase_xdft_8 = angle(xdft_8); figure, subplot(2,1,1); stem(k, mag_xdft_8), grid on; title( Magnitude of 8-point DFT of x[n] ), xlabel( k ), ylabel( X[k] ); xlim([-0.2 8.2]); subplot(2,1,2); stem(k, phase_xdft_8), grid on; title( Phase of 8-point DFT of x[n] ), xlabel( k ), ylabel( < X[k] (radians) ); xlim([-0.2 8.2]); 5 Homework - Due 06/28/2011 at 5:00 PM 1. Write a function called func_mydft(x,n) to compute the DFT of the sequence x. Note N is the DFT length which may be different from the sequence length M. If N > M the function should zero pad the input before computing 2

the DFT. If N < M then the input must be truncated. Test your function by comparing the the output of your function with that obtained by fft. You can use randn function to generate the test vectors. 2. Let x[n] be a discrete time sequence: { (0.7) n, 0 n 7 (a) Determine the analytical expression for the DTFT of x[n] and plot the magnitude and phase of the DTFT. (b) Compute in MATLAB the 8-point DFT of x[n], 0 n 7 using the DFT function you wrote in Problem 1. Plot the magnitude and phase. You can use the stem, abs, and angle commands. (c) Compute, in MATLAB, the 16-point DFT of x[n], 0 n 15 and stem plot its magnitude and phase. This can be accomplished by modifying the commands provided in part (b). Comment on the effect of zero-padding the signal on its DFT. (d) Compute, in MATLAB, the 128-point DFT of x[n], 0 n 127 and plot its magnitude and phase. Note: the plot command is used instead of stem when many dense points exist to avoid appearance of a black blob. (e) Compare the results from part (d) to the plots of part (a). How does this relate to the relationship between digital frequency ω and DFT index k? 3. Consider the following two sequences: [1 1 1 1] y[n] = [1 1 1 1] (a) Perform the linear convolution of the two sequences using the conv command. Plot the result using stem. (b) Analytically perform the cyclic convolution of the two sequences. (c) Compute the DFT of x[n] and y[n]. Store the result in vectors Xk and Yk. Now perform a point-by-point product of Xk and Yk. i.e. compute Zk = Xk.* Yk. Take the inverse DFT of Zk. In case you get complexvalued outputs, extract the real part using the real command. Verify that your result agrees with the result obtained in Part (b). Plot your result using stem. How many samples of the result agree with the result in Part (a). (d) Increase the length of x[n] and y[n] by zero-padding the sequences. First add one zero to both the sequences. Repeat the steps in Part (b). How many samples agree with the result in Part (a). How many zeros will be needed to obtain the result in Part (a). (e) Consider the following two sequences: [ 3 5 8 6 2 2] y[n] = [1 1 4 2] Repeat parts (a) through (d) for this new case. Can you generalize the results for any vector x of length L and any vector y of length M (i.e. how many zeros should you add to each of x and y so that the output of circular convolution is equal to that of linear convolution)? 4. Download the file tones.mat from the course web page. The file contains the a signal which has multiple tones in it. Load the signal using the following commands, s = load(tones.mat); x = s.y1; 3

The variable x should now contain the signal. (a) Compute the DFT of x using a transform length N = 25. Plot the magnitude of the DFT using the plot command. How many distinct frequencies do you see? (b) Experiment with the sequence length (by adding a different number of zeros). Compute the DFT for these different sequence lengths obtained by zero-padding. Can you find more frequencies? How many tones can you distinguish and what are their values? 5. Consider the following signal { cos(2π 100t) + cos(2π 102t), 0 t 0.3 sec x(t) = cos(2π 103t) + cos(2π 105t), 0.3 t 0.9 sec Note that the signal not only has different frequencies in it but also that the frequency content of the signal changes with time. Assume that we are sampling the signal at 1 KHz, that is F s = 1000 Hz to obtain a discrete time signal x[n] given below: { cos(0.2πn) + cos(0.204πn), 0 n 300 cos(0.206πn) + cos(0.210πn), 300 < n 900 In this problem, we would like to find out the frequency content of this signal as accurately as possible. We will do this by applying a windowing operation to the signal. (a) First let us look at the effects of DFT sampling on two window functions w 1 [n] and w 2 [n] given below: { 1, n = 0, 1,..., 300 w 1 [n] = w 1 [n] = { 1, n = 0, 1,..., 600 i. Compute the M = 900 point DFT of the window functions w 1 [n], w 2 [n]. Plot the magnitude of the DFT s. How do these compare (comment and explain analytically why you got the following plots)? You may plot only the first 100 samples of the spectrum to give a clearer picture. ii. Compute the M = 1800 point DFT of the window functions w 1 [n], w 2 [n] and plot the magnitude of the computed DFT s. Do you see any differences compared to Part i? Again, you may plot only the first 100 samples of the spectrum. (b) We will now try to perform spectral estimation of the signal x[n]. We will do this by windowing the signal. Let us first consider the signal in the interval 0 n 300. In this period the signal does not change its frequency content. i. Multiply x[n] by the window function w 1 [n] to obtain x 1 [n] = x[n]w 1 [n] (Note: this is equivalent to extracting the first 300 samples of x[n]). Compute the N = 300 point DFT of x 1 [n]. Plot the magnitude. Comment on the frequency content. ii. Next multiply x[n] by the shifted window function to obtain x 2 [n] = x[n]w 1 [n 300]. Find the N = 300 point DFT of x 2 [n]. Comment on its frequency content. Are the results of this exercise satisfactory? (c) Let us now use the window w 2 [n] to perform the spectral estimation. Multiply x[n] by w 2 [n] to obtain x 3 [n] = x[n]w 2 [n]. Compute the DFT of x 3 [n] and plot its magnitude. Did the frequency resolution improve? 4

6. In this exercise we will consider a simple example for using the spectrogram function in MATLAB. Download the file mtlb.mat file from the course web page. This file contains a speech signal of duration 4001 samples sampled at 7418 Hz. We will compute the Short Time Fourier Transform (STFT) of this signal using the spectrogram function. (a) First load the file using load as shown below: load mtlb; Now plot the speech signal using the plot command. (b) We will use the following form of the spectrogram function: spectrogram(x,len,overlap,n,fs,axis) here x = vector that hold input signal len = an integer value here denotes the window length overlap = number of samples by which sections overlap N = The DFT length Fs = Sampling frequency axis = The axis to be used for the frequency. You can specify axis as y-axis Deliverables Generate the spectrogram of the speech signal for window length of 256, time lapse between blocks of 35, and transform length of 512 using the spectrogram command. Comment on your results. Email your code, figures, calculation and answers as a.pdf or.doc file to ece311lab.uiuc@gmail.com. Be sure to name your document in the form- ECE311Lab2 firstname lastname.doc/pdf. Late reports will reduce the grade by 20% per day. Make sure to present a clear and concise report having figures labeled and centered. Reminder: Homework is due on 06/28/2011 5