DSP Laboratory (EELE 4110) Lab#3 Discrete Time Signals

Similar documents
LAB # 3 HANDOUT. y(n)=t[x(n)] Discrete systems have different classifications based on the input and output relation:

Analog vs. discrete signals

ECE 308 Discrete-Time Signals and Systems

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

Discrete-Time Signals and Systems

Digital Signal Processing Lecture 4

EEL3135: Homework #4

Lecture 19 IIR Filters

ELEG 305: Digital Signal Processing

Introduction to DSP Time Domain Representation of Signals and Systems


UNIT 1. SIGNALS AND SYSTEM

Discrete-Time Systems

Digital Signal Processing Module 1 Analysis of Discrete time Linear Time - Invariant Systems

Properties of LTI Systems

Digital Signal Processing, Homework 1, Spring 2013, Prof. C.D. Chung

Chap 2. Discrete-Time Signals and Systems

Digital Signal Processing

Discrete-Time Signals & Systems

Digital Signal Processing Lecture 3 - Discrete-Time Systems

Lecture 11 FIR Filters

EE538 Final Exam Fall 2007 Mon, Dec 10, 8-10 am RHPH 127 Dec. 10, Cover Sheet

Z - Transform. It offers the techniques for digital filter design and frequency analysis of digital signals.

Linear Convolution Using FFT

Examples. 2-input, 1-output discrete-time systems: 1-input, 1-output discrete-time systems:

(t ) a 1. (t ).x 1..y 1

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

Review of Discrete-Time System

VU Signal and Image Processing

Discrete-time Signals and Systems in

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

ELEN E4810: Digital Signal Processing Topic 2: Time domain

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

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

Frequency-Domain C/S of LTI Systems

EEM 409. Random Signals. Problem Set-2: (Power Spectral Density, LTI Systems with Random Inputs) Problem 1: Problem 2:

Digital Signal Processing I Final Exam Fall 2008 ECE Dec Cover Sheet

6.02 Fall 2012 Lecture #10

Interchange of Filtering and Downsampling/Upsampling

EE123 Digital Signal Processing

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

Probability Space. J. McNames Portland State University ECE 538/638 Stochastic Signals Ver

Review of Fundamentals of Digital Signal Processing

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

Lecture 4: FT Pairs, Random Signals and z-transform

Solutions. Number of Problems: 10

Multidimensional digital signal processing

E : Lecture 1 Introduction

Digital Filters Ying Sun

Lecture 2 Discrete-Time LTI Systems: Introduction

The Discrete-Time Fourier

University Question Paper Solution

Module 3. Convolution. Aim

ECE-314 Fall 2012 Review Questions for Midterm Examination II

EE482: Digital Signal Processing Applications

ECE-S Introduction to Digital Signal Processing Lecture 3C Properties of Autocorrelation and Correlation

Introduction to Digital Signal Processing

DIGITAL SIGNAL PROCESSING LECTURE 1

Discrete-time signals and systems

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

Problem Value Score No/Wrong Rec

EE538 Final Exam Fall :20 pm -5:20 pm PHYS 223 Dec. 17, Cover Sheet

EE482: Digital Signal Processing Applications

Let H(z) = P(z)/Q(z) be the system function of a rational form. Let us represent both P(z) and Q(z) as polynomials of z (not z -1 )

2. CONVOLUTION. Convolution sum. Response of d.t. LTI systems at a certain input signal

5. Time-Domain Analysis of Discrete-Time Signals and Systems

UNIT-II Z-TRANSFORM. This expression is also called a one sided z-transform. This non causal sequence produces positive powers of z in X (z).

III. Time Domain Analysis of systems

Z-Transform. x (n) Sampler

Chapter 3 Convolution Representation

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

LECTURE NOTES DIGITAL SIGNAL PROCESSING III B.TECH II SEMESTER (JNTUK R 13)

3.2 Complex Sinusoids and Frequency Response of LTI Systems

Review of Fundamentals of Digital Signal Processing

Discrete-Time Fourier Transform (DTFT)

Chapter 2 Time-Domain Representations of LTI Systems

ECE4270 Fundamentals of DSP Lecture 20. Fixed-Point Arithmetic in FIR and IIR Filters (part I) Overview of Lecture. Overflow. FIR Digital Filter

( ) John A. Quinn Lecture. ESE 531: Digital Signal Processing. Lecture Outline. Frequency Response of LTI System. Example: Zero on Real Axis

/ (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

Signals & Systems Handout #4

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

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

PS403 - Digital Signal processing

Lecture 27 Frequency Response 2

Using MATLAB with the Convolution Method

P 1.5 X 4.5 / X 2 and (iii) The smallest value of n for

Discrete-Time David Johns and Ken Martin University of Toronto

Stability Condition in Terms of the Pole Locations

Lecture 7 - IIR Filters

ECGR4124 Digital Signal Processing Exam 2 Spring 2017

LTI Systems (Continuous & Discrete) - Basics

Lecture 3 January 23

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

How to manipulate Frequencies in Discrete-time Domain? Two Main Approaches

A. Relationship of DSP to other Fields.

LTI H. the system H when xn [ ] is the input.

z-transforms Definition of the z-transform Chapter

is to follow these steps (note that n is some fixed value; it will range over all values for which y [n]

The Convolution Sum for Discrete-Time LTI Systems

Final Exam January 31, Solutions

Transcription:

Islamic University of Gaza Faculty of Engineering Electrical Engineering Department Spring- ENG.MOHAMMED ELASMER DSP Laboratory (EELE 4) Lab#3 Discrete Time Signals DISCRETE-TIME SIGNALS Signals are broadly classified into analog and discrete signals. An analog signal will be denoted by x(t), in which the variable t can represent any physical quantity, but we will assume that it represents time in seconds. A discrete signal will be denoted by x(n), in which the variable n is integer-valued and represents discrete instances in time. Therefore it is also called a discrete-time signal, which is a number sequence and will be denoted by one of the following notations: x n = x n = {, x, x, x, } where the up-arrow indicates the sample at n =. In MATLAB we can represent a finite-duration sequence by a row vector of appropriate values. However, such a vector does not have any representation of x(n) would require two vectors, one each for x and n. For example, a sequence: x n = {,,,,,4,3,7} Can be represented in MATLAB by: >> n=[-3,-,-,,,,3,4]; >> x=[,,-,,,4,3,7]; Generally, we will use the x-vector representation alone when the sample position information is not required or when such information is trivial (e.g. when the sequence begins at n=). An arbitrary infinite-duration sequence cannot be represented in MATLAB due to the finite memory limitations. TYPES OF SEQUENCES We use several elementary sequences in digital signal processing for analysis purposes. Their definitions and MATLAB representations are given below.. Unit sample sequence δ n = n = n

However, the logical relation n == is an elegant way of implementing δ(n). For example, to implement: δ n n o = n = n o n n o Over the interval n n n, we will use the following MATLAB function: % Function to generate x(n)=delta(n-no), n<=n<=n function [x,n]=impseq(no,n,n) n=[n:n]; x=[(n-no) == ]; end In other way: % n=,n=6,no=5 n=[:6] x=[(n-5) == ] stem(n,x) or: [x,n]=impseq(5,,6) Results: n = 3 4 5 6 x =.8.6.4. 3 4 5 6 Figure 4. impseq(5,,6). Unit step sequence u n = n n < In MATLAB the function zeros(,n) generates a row vector of N zeros, which can be used to implement u(n) over a finite interval. However, the logical relation n == is an elegant way of implementing u(n). For example, to implement u n n o = n n o n < n o Over the interval n n n, we will use the following MATLAB function: % Function to generate x(n)=step(n-no), n<=n<=n function [x,n]=stepseq(no,n,n) n=[n:n]; x=[(n-no) >= ]; end

In other way: % n=,n=6,no=5 n=[:6] x=[(n-3) >= ] stem(n,x) or: [x,n]=stepseq(3,,6) Results: n = 3 4 5 6 x =.8.6.4. 3. Real-valued exponential sequence: Figure 4. stepseq(3,,6) x n = a n, n; aεr In MATLAB an array operator. is required to implement a real exponential sequence. For example, to generate x(n) = (.9) n, n, we will need the following MATLAB script: >> n=[:]; >> x=(.9).^n; 4. Complex-valued exponential sequence: x n = e σ+j ω o n, n Where σ is called an attenuation and ω o is the frequency in radians. MATLAB function script is used to generate exponential sequences. For example, to generate x(n) = exp [( + j3) n], n, we will the following MATLAB script: >> n=[:]; >> x=exp(+3i).^n; 5. Sinusoidal sequence:.5 3 3.5 4 4.5 5 5.5 6 x n = cos ω o n + θ, n Where θ is the phase in radians. A MATLAB function cos(or sin) used to generate sinusoidal sequences. For example, to generate x(n) =3cos(.lπn+π/3)+sin(.5πn), n, we will need the following MATLAB script: >> n=[:]; >> x=3*cos(.*pi*n+pi/3)+*sin(.5*pi*n);

6. Random sequences: Many practical sequences can't be described by mathematical expressions. Those sequences are called random (stochastic) sequences and are characterized by parameters of the associated probability density function or their statistical moments. In MATLAB there are two types of random sequences. The rand(,n) generates a length N random sequence whose elements are uniformly distributed between [,]. The randn(,n) generates a length N Guassian random sequence with mean and variance. 7. Periodic sequences: A sequence x(n) is periodic if x(n)=x(n+n), the smallest integer N satisfies the previous relation is called the fundamental period. OPERATIONS ON SEQUENCES. Signal addition: {x n } + {x n } = {x n + x n } It's implemented by MATLAB using the operator "+". Notice that the two sequences x (n) and x (n) must have the same length and the same indexing. We can use the following MATLAB function to demonstrate the discrete sequences additions: % Function adds two discrete time sequences y(n)=x(n)+x(n) function [y,n]=sigadd(x,n,x,n) n=min(min(n),min(n)):max(max(n),max(n)); y=zeros(,length(n)); y=y; y(find((n>=min(n))&(n<=max(n))==))=x; y(find((n>=min(n))&(n<=max(n))==))=x; y=y+y; end To understand the algorithm of the sigadd function, we will firstly describe find function. >> help find Find indices of nonzero elements. ind = FIND(X) returns the linear indices corresponding to the nonzero entries of the array X. for example: >> X = [ 4-3 8 6]; >> indices = find(x) %% means find x that is not equal to zero indices = 3 4 8 9 The indices,3,4,8 and 9 of a vector X has a non zero value.

Other example: >> X = [ 4-3 8 6]; >> ind = find(x > ) %% X> = 4,8,6 which indices=3,8,9 ind = 3 8 9 find(x>) returns linear indices corresponding to the entries of X that are greater than. The lines below can be used to add two sequences x(n) and x(n), x=[,,4,6,8]; % line# n=[,,,3,4]; % line# x=[,3,5,7,9]; % line#3 n=[-,-,,,]; % line#4 n=min(min(n),min(n)):max(max(n),max(n)); % line#5 y=zeros(,length(n)); % line#6 y=y; % line#7 y(find((n>=min(n))&(n<=max(n))==))=x; % line#8 y(find((n>=min(n))&(n<=max(n))==))=x; % line#9 y=y+y; % line# n = - - 3 4 >> A=n>=min(n) % n>= {,,,,,,} >> B=n<=max(n) % n<=4 {,,,,,,} >> A&B >> find(a&b==) % index A = B = ans = ans =3 4 5 6 7 The values of all workspace variables can be seen in the following table, line# line# line#3 line#4 n x n x - - 3 5 7 4 9 3 6 4 8 line#5 line#6 line#7 line#8 line#9 line# N y y y y y+y - - 3 3 5 5 7 9 4 9 3 3 6 6 4 8 8 Or using sidadd function x=[,,4,6,8]; n=[,,,3,4]; x=[,3,5,7,9]; n=[-,-,,,]; [y,n]=sigadd(x,n,x,n) y = 3 5 9 3 6 8 n =- - 3 4

. Signal multiplication: x n. {x n } = {x n x n } It's implemented in MATLAB by array operator ".*". Once again the similar restrictions apply for the ".*" operator as "+" We can use the following MATLAB function to demonstrate the discrete sequences multiplication: % Function multiplies two discrete time sequences y(n)=x(n)*x(n) function [y,n]=sigmult(x,n,x,n) n=(min(n),min(n)):(max(n),max(n)); y=zeros(,length(n)); y=y; y=find((n>=min(n))&(n<=max(n==))=x; y=find((n>=min(n))&(n<=max(n==))=x; y=y.*y; end 3. Signal scaling: In this operation each sample is multiplied by a scalar α. a x n = {ax n } The operator "*" is used to implement scaling in MATLAB. 4. Signal shifting: In this operation each sample is shifted by amount of k to obtain the shifted sequence y(n): y n = x n k This is can be implemented by the following MATLAB function: % Function does signal shifting y(n)=x(n-no) function [y,n]=sigshift(x,n,no) n=n+no; y=x; end For example: x=[,,,]; n=[,,3,4]; n=n+6; n3=n-6; %[y,n]=sigshift(x,n,6) %[y,n3]=sigshift(x,n,-6) stem(n,x),hold on,stem(n,x),hold on,stem(n3,x)

.5.5 5. Signal folding: -7-6 -5-4 -3 - - 3 4 5 6 7 8 9 Figure 4.3 sigshift(x,n,no) In this operation each sample of x(n) is flipped around n= to obtain a folded sequence y(n): y n = x n In MATLAB this operation is implemented as follows: % Function does signal folding y(n)=x(-n) function [y,n]=sigfold(x,n) y=fliplr(x); n=-fliplr(n); end >> help fliplr FLIPLR Flip matrix in left/right direction. FLIPLR(X) returns X with row preserved and columns flipped in the left/right direction. X = 3 becomes 3 For example: x=[,,3]; n=[,3,4]; y=fliplr(x); n=-fliplr(n); % [y,n]=sigfold(x,n) stem(n,x),hold on,stem(n,y) 4 3-6 -5-4 -3 - - 3 4 5 6 Figure 4.4 sigfold(x,n)

6. Sample summation: This operation adds all sample values of x(n) between n and n. n n =n x n = x n + + x n And it's implemented by MATLAB by: >> sum(x(n:n)); 7. Sample product: This operation multiplies all sample values of x(n) between n and n. n o n x n n And it's implemented by MATLAB by: >> prod(x(n:n)); 8. Signal energy: The energy of a sequence x(n) is given by: E x = x n n= The energy of a finite duration x(n) can be computed in MATLAB using: >> E=sum(abs(x).^); 9. Sample power: The average power of a periodic sequence with fundamental period N is given by: P x = N N n = x n

Exercise Generate and plot each of the following sequences over the indicated intervals: a) x (n) = δ(n + ) δ(n 4), 5 n 5 b) x (n) = n[u(n) u(n )] + exp(.3(n )) [u(n ) u(n )], n c) x 3 (n)(n) = cos(.4πn) +.w(n), n 5, where w(n) is a Guassian random sequence with and variance. d) x (n)(n) = exp(. + j.3)n, n DISCRETE SYSTEMS Mathematically, a discrete time system is described as an operator T[.] that takes a sequence x(n) (called excitation) and transforms it into another sequence y(n) (called response). y n = T x n Discrete systems are classified into linear and non-linear systems. We will deal mostly on linear systems. Linear systems: A discrete time system is called linear system if it satisfies the superposition principle. L a x n + a x n = a L x n + a L x n, a, a, x n, x n Linear time-invariant (LTI) systems: A linear system in which an input-output pair, x(n) and y(n), is invariant to a shift n in time is called a linear-time invariant system. For LTI system the L[.] and the shifting operators are available as shown below. The impulse response of an LTI system is given by h(n). And it's represented mathematically by the linear convolution sum:

We will now explore some of the LTI system properties.. Stability: This is a very important concept in linear system theory. The primary reason for considering stability is to void building harmful systems and to avoid burnout or saturation in systems operation. A system is said to be bounded-input bounded output stable if every input produced bounded output. x n < y n <, x, y An LTI system is BIBO if and only if its impulse response is absolutely summable. BIBO Stability n= h n < For example: for the system y n =.9 n u n n=:; y=(-.9).^n; sum(y) ans =.563, then the system is stable.. Casuality This important concept is necessary to make sure that systems can be built. A system is said to be casual if the output at index no depends only on the input up to and including the index no; that is the output doesn't depend on the future values An LTI system is casual if and only if its impulse response: CONVOLUTION In DSP, the convolution is an important operation as it has many uses. It can be evaluated in many ways. MATLAB provides a built-in function called conv that computes the convolution between two finite duration sequences. The conv function assumes that the two sequences begin at n=. Example: Given the following two sequences x n = 3,, 7,,, 4,, 3 n 3 h n =, 3,, 5,,, n 4 Determine the convolution y(n)=x(n)*h(n). >> x=[3,,7,,-,4,]; >> h=[,3,,-5,,]; >> conv(x,h) ans = 6 3 47 6-5 -5 4 8 - -3 8

Note that the conv function doesn't provide any timing information if the sequences have arbitrary support. A simple extension of the conv function called conv_m, which perform the convolution of arbitrary support sequences. % Modified convolution routine function [y,ny]=conv_m(x,nx,h,nh) nyb=nx()+nh(); nye=nx(length(x))+nh(length(h)); ny=[nyb:nye]; y=conv(x,h) end Perform the convolution in previous example using conv_m function. x=[3 7-4 ]; nx=[-3,-,-,,,,3]; h=[ 3-5 ]; nh=[-,,,,3,4]; [y,ny]=conv_m(x,nx,h,nh) y = 6 3 47 6-5 -5 4 8 - -3 8 ny = -4-3 - - 3 4 5 6 7 Example: Consider a LTI system with input x n =, 9 n, else and the impulse response h n = n u n. Using conv_m find the output y(n). nx=-9:; x=[,,,,,,,,,]; nh=:; h=().^-nh; [y,ny]=conv_m(x,nx,h,nh) stem(ny,y) y(n)=x(n)*h(n).8.6.4..8.6.4. - -5 5 5 Figure 4.5 conv_m (system response)

Exercise Consider that we have an input x(n) of finite duration sequence: x n = u n u(n ) While the impulse response of infinite duration: h n =.9 n u(n) Compute the convolution y(n)=x(n)*h(n). CORRELATION The cross-correlation between two sequences can be evaluated by the formula: With the auto-correlation in the form: r xy r ( ) x ( n) y ( n ),,,,... n r ( ) x ( n)* y ( n) ( ) r ( ) In MATLAB, cross-correlation between two sequences x(n) and y(n) is implemented using xcorr(x,y) function and the auto-correlation of a sequence x(n) is computed. using xcorr(x). Example: Let x n =,, 4, and h(n) = {,,, } xx >> x=[,,4]; >> h=[,,,,]; >> y=xcorr(x,h) y = 3 7 7 7 6 4 Also we can used convolution (conv_m function ) x=[,,4] nx=[,,] h=[,,,,] nh=[-4,-3,-,-,] [y,ny]=conv_m(x,nx,h,nh) y = 3 7 7 7 6 4 ny = -4-3 - - xy r xy yx ( ) x ( n) x ( n ),,,,... n r ( ) x ( n)* x ( n) xx E r () x ( n) x xx n

Exercise 3 Let, x n = 3,, 7,,, 4,, 3 n 3, and y(n) be its noise corrupted- and-shifted version: y n = x n + w(n) Where w(n) is a Guassian random sequence with mean and variance. Compute the cross-correlation between y(n) and x(n). DIFFERENCE EQUATIONS An LTI discrete system can also be described by a linear constant coefficients difference equation of the form: N k= M a k y n k = b m x n m, n m= Another form of the previous equation is: M y n = b m x n m m = N k= a k y n k A routine called filter is available in MATLAB to solve the difference equation numerically, given the input and the difference equation coefficients. This routine is invoked as follows: >> y=filter(b,a,x) Where b=[b b b...bm], a=[a a a...a M] are the coefficient arrays of the difference equation and x is the input sequence. The output y has the same length as x and insures that a. A useful use of filter function is that it can be used to find the numerical evaluation of the convolution of two sequences if one of them has infinite length. That's because we can't use conv function when one or both sequences of the convolution are of infinite length. Example: Suppose we have two systems with the following difference equations y(n) = x(n) + x(n ) + x(n ) Assume that y( ) =. (a) Find the impulse responses of these systems. (b) State whether each system is FIR or IIR, and why. (c) State whether each system is stable, and show why. b=[ ]; a=[]; [x,n]=impseq(,-,); h=filter(b,a,x); stem(n,h)

.5.5 - - Figure 4.6 System impulse response From impulse response we can see that the system is FIR (and all FIR systems are stable). or if the sequence is summable sequence then the system is stable n = h n = + + = 4 < stable system Exercise 4 Given the following difference equations: y(n) =.9y(n ) + x(n). y n y n +.9y n = x(n). a. Calculate and plot the impulse response h(n) at x =,.......... b. Calculate and plot the unit step response s(n) at x =,.......... c. State whether each system is stable, and show why. d. State whether each system is FIR or IIR, and why.