Sei sulla pagina 1di 32

4/18/2012

Manipulate Sampled Signal Lecture 2a

4/18/2012

4/18/2012

4/18/2012

4/18/2012

4/18/2012

4/18/2012

4/18/2012

4/18/2012

4/18/2012

10

4/18/2012

11

4/18/2012

12

4/18/2012

13

4/18/2012

14

4/18/2012

15

4/18/2012

16

4/18/2012

Type the following Matlab commands generate the following graphs:


%Graph 1 %Sawtooth sequence n = 0:20; y = sawtooth((n*pi)/4,1); stem(n,y); figure; y1 = sawtooth((n*pi)/4,0.5); stem(n,y1); %Graph 2 %Square sequence figure; n = 0:20; y = square((n*pi)/4,25); stem(n,y); figure; y = square((n*pi)/4,75); stem(n,y);
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1

0.8 0.6 0.4 0.2 0 -0.2

1 0.8 0.6 0.4 0.2 0 -0.2

-0.4
-0.4

-0.6 -0.8 -1

-0.6 -0.8

10

12

14

16

18

20

-1

10

12

14

16

18

20

10

12

14

16

18

20

10

12

14

16

18

20

PS: Type help function_name for brief description of a specific function.

17

4/18/2012

Operations on Sequences A single-input, single-output discrete-time system operates on a sequence, called the input sequence, according to some prescribed rules and develop another sequence, called the output sequence, usually with more desirable properties. Example : to remove noise from an corrupted input signal. Basic operations : x[n] y[n] w1[n] = x[n]y[n] modulation / product w1[n] x[n] + y[n] w2[n] = x[n] + y[n] addition w2[n]

x[n]

w3[n]

x[n]

w4[n]

w3[n] = Ax[n] multiplication x[n]


D-1

w4[n] = x[n - 1] unit delay w5[n]

w5[n] = x[n + 1] unit advance Time reversal : w6 = x[-n], a time-reversed version of x[-n]. N-delay : w7 = x[n-N], if N is positive. If N is negative it becomes an advance of the sequence

18

4/18/2012

Example : x[n] = { -1.1, 2.0, 7.4, -3.6, 0.1 }, y[n] = { 4.1, 0.8, -1.0, 4.2, 3.7 } w1[n] = {-4.51, 1.60, -7.40, -15.12, 0.37} w2[n] = {3.00, 2.80, 6.40, 0.60, 3.80} w3[n] = {-4.95, 9.00, 33.30, -16.20, 0.45} where A = 4.5 w4[n] = {*, -1.10, 2.00, 7.40, -3.60, 0.10} w5[n] = {-1.10, 2.00, 7.40, -3.60, 0.10 } w6[n] = {0.10, -3.60, 7.40, 2.00, -1.10} w7[n] = {*, *, *, -1.10, 2.00, 7.40, -3.60, 0.10 } where N = 3.
U1f19.m

Modulation examples : To transform a sequence with low-frequency sinusoidal components to a sequence with high-frequency components.

Example : x[n] = {-1.1, 2.0, 7.4}, y[n] = {4.1, 0.8, -1.0, 4.2, 3.7} w1[n] = x[n] y[n] = {-4.51, 1.60, -7.40, 0, 0} w2[n] = x[n] + y[n] = {3.00, 2.80, 6.40, 4.20, 3.70} Note that x[n] has been appended with two zeros to make it as sequence of length of 5 in order to perform the above operations. Example :
x[n] D x[n-1] D x[n-2] D x[n-3]

What is y[n], the output of the discrete system, in terms of x[n] ?


4

2
+ y[n]

y[n] = 1x[n] + 2x[n-1] + 3x[n-2] + 4x[n-3]

19

4/18/2012

x[n]

b0 + b1 D a0 D y[n-1] b2 D x[n-2] y[n-2] a1 D y[n]

x[n-1]

What is y[n], the output of the discrete system ? y[n] = b0x[n] + b1x[n-1] + b2x[n-2] + a0y[n-1] + a1y[n-2]

System Impulse Response


1
-3 -2 -1

[n]
1 2 3 4 5 6 7

1 n
-3 -2 -1

2 h[n] 3
1 2 3 4 5 6 7

x[n]

-3 -2 -1

1 2 3

5 6 7

Convolution: y[n] = x[n] h[n]

20

4/18/2012

Input-Output Relationship An LTI discrete-time system is completely defined by its impulse response i.e. knowing the impulse response, we can compute the output of the system to any arbitrary input. Example : Let h[n] denotes the impulse response of the LTI discrete-time system of interest. Let the input be x[n] = 0.5 [n + 2] + 1.5 [n - 1] - [n - 2] + [n - 4] + 0.75 [n - 6] Since the system is time-invariant, its responses to 0.5[n + 2], 1.5[n - 1], [n - 2], [n - 4] and 0.75[n - 6] will be 0.5h[n + 2], 1.5h[n - 1], h[n - 2], h[n - 4] and 0.75h[n - 6] respectively. Therefore, the output will be y[n] = 0.5 h[n + 2] + 1.5 h[n - 1] - h[n - 2] + h[n - 4] + 0.75 h[n - 6]

We can generalise the above result for an arbitrary input sequence x[n] that can be expressed as

y[n] =
or alternatively,

x[k ]h[n k ]
k =

y[n ] =

x[n k ]h[k ]
k =

A LTI system is completely characterized by its impulse response h[n] in the sense that, given h[n], it is possible to compute the output y[n] due to any input x[n].

21

4/18/2012

The above two equations are called the convolution sum of the sequences x[n] and h[n]. It can be represented compactly as : y[n] = x[n] * h[n] where * denotes the convolution sum. Example : Let the input and impulse response of a LTI discretetime system be x[n] = [n + 1] + 2 [n] + 3 [n - 1] - [n - 2] and h[n] = [n] - [n - 1] + 2 [n - 2]. Determine the output, y[n].

Methods for Convolution


Graphical / sliding method Frequency domain evaluation Matlab: y = conv(x, h) Analytical evaluation

Convolution Formula:

Graphical Convolution

22

4/18/2012

Convolution by Graphical Method

Convolution by Graphical Method (cont)

23

4/18/2012

Graphical Convolution

x[n] = u[n] - u[n-6] h [ n ] = e -n u [ n ] y [n ] = x [k ] h [n - k ]


y[0] = x[k] h[0 - k]
y[0] = . + 0 h[-5] + 0 h[-4] + 0 h[-3] + 0 h[-2] + 0 h[-1] + 1 . 1 + x[1] 0 + x[2] 0 + x[3] 0 + x[4] 0 + x[5] 0 + . = 1

y[1] = x[k] h[1 - k]


[1] = . + 0 h[-5] + 0 h[-4] + 0 h[-3] + 0 h[-2] + 0 h[-1] + 1 . e-1 + 1 1 + x[2] 0 + x[3] 0 + x[4] 0 + y[0] x[5] 0 + . = 1.3679..

24

4/18/2012

Convolution by Sliding Method For simple sequences it is possible to determine the output of convolution by reversing one of the two convolving sequences and slide it against the other fixed sequence. The sum of the resultant sequence for every slide step, n is equivalent to y[n]. See the diagrams in the next pages for the sliding technique.

Let h[k] = Let x[k] = h[-2-k] x[k] h[-2-k] y[-2] = x[k] h[-1-k] y[-1] =

0 0

1 -1 2

k=0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 3 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

2 -1 1

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

3 -1 0 0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

2 -1 1 0 0 0 0 0

=
0 0

=0

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

0 0 0

3 -1 0 0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

2 -1 1 0

=
0 0 1 0

=1

25

4/18/2012

x[k] h[-k] y[0] = x[k] h[1-k] y[1] = x[k] h[2-k] y[2] =

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

0 0 0

0 0 0

3 -1 0 0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

2 -1 1

=
0 -1 2

=1

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

3 -1 0 0 0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

2 -1 1

=
2 -2 3

=3

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

3 -1 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 2 -1 1

=
0 4 -3 -1 0

=0

x[k] h[3-k]
[3] y[4] =

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

3 -1 0 2 -1 1 6 1 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0

=
0 0

=7

x[k] h[4-k]
[4] = y[5]

0 0 0

0 0 0

0 0 0

0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

3 -1 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 2 -1 1 0

=
0 0 0 -2 0

= -2

y[n]

0 0

7 -2 0

n (+ve)

26

4/18/2012

Convolution in Matlab Matlab provides a built-in function called conv which can be used to compute the convolution between two finite-length sequences. It assumes that the two sequences begin at n = 0. Example (2-15) : Find the convolution output y[n] between x[n] = [ 3 11 7 0 -1 4 2 ] and h[n] = [ 2 3 0 -5 2 1].
x = [ 3 11 7 0 -1 4 2]; h = [ 2 3 0 -5 2 1]; y = conv(x,h) y = 6 31 47 6 -51 -5 41 18 -22 -3 8 2

The convolution between two sequences of lengths N and M always results in an output sequence of length N + M - 1.

However, conv does not provide or accept any timing information. Example : Find the convolution output y[n] between x[n] = [ 3 11 7 0 -1 4 2 ] for -3 n 3 and h[n] = [ 2 3 0 -5 2 1] for -1 n 4. The sequence generated in the previous example can be used with additional timing information need to be determined as follows : Starting point for y[n] : ny-s = -3 + -1 = -4. End point for y[n] : ny-e = 3 + 4 = 7
y = 6 31 47 6 -51 -5 41 18 -22 -3 8 2

n=0

27

4/18/2012

Example : Determine the output y[n] for an LTI system with input of x[n] = u[n] - u[n-10] and h[n] = 0.9n u[n]. To generate y[n] using Matlab we need to define finite-length sequences. Assume that x[n] and h[n] are defined for 0 n < 30
x[ n ]
1 am plitude am plitude 6 4 2 0 0 5 10 15 n 20 25 0 10 20 30 n 40 50

y[ n ]

0.5

1 am plitude

h[ n]

Starting point is 0 while end point is 29+29 = 58.

0.5

0 0 5 10 15 n 20 25

U2f7.m

Example : Determine the response of a system with h[n] = - u[n] + u[n-3] + 2u[n-4] and input, x[n] = [ 0 0 -2 -1 2 3 0 0 ] for 2 n 5.
4 2 0 -2 -10 -2 3 2 am plitude 1 0 -1 -2 -5 0 n 5 10 0 n 2 4 -5 0 n 5 10 15

x[ n ]
10 am plitude 5 0 -5

y[ n ]

am plitude

h[ n]

U2f7a.m

28

4/18/2012

A new function conv_m has been defined and used here :


function [y,ny] = conv_m(x,nx,h,nh) %Modified convolution routine for signal processing %-------------------------------------------------% y = convolution result % ny = time index for y % x = input vector % nx = time index for x % h = impulse response % nh = time index for h nyb = nx(1)+nh(1); ny = [nyb:nye]; y = conv(x,h); nye = nx(length(x)) + nh(length(h));

The function take into account the timing information of the input sequences expressed in the form of a matrix : [ starting value of n : ending value of n ]. Output sequence is returned together with timing information matrix.

Properties of Convolution - Assume that x[n], h[n] and z[n] are sequences Commutativity x[n] * y[n] = y[n] * x[n] Associativity x[n] * ( y[n] * z[n] ) = ( x[n] * y[n] ) * z[n] Distributivity x[n] * ( y[n] + z[n] ) = x[n] * y[n] + x[n] * z[n] The identity sequence for convolution operator is [n] x[n] * [n] = [n] * x[n] = x[n] The convolution of delayed unit sample sequence with x[n] x[n] * [n - k] = x[n k]

29

4/18/2012

Simple Interconnection Schemes There are two widely used schemes for developing complex LTI discrete-time systems from simple LTI discrete-time systems. Cascade Connection h1[n] h2[n] h1[n] * h2[n] h2[n] h1[n]

The overall impulse response h[n] of the cascade of two filters of impulse responses h1[n] and h2[n] is given by h[n] = h1[n] * h2[n]

The cascade scheme is employed in the development of an inverse system. If two LTI systems of impulse responses h1[n] and h2[n] related to each other as follows : h1[n] * h2[n] = [n] then the two systems are said to be inverse of each other. Parallel Connection h1[n]
+

h1[n] + h2[n]

h2[n]

30

4/18/2012

Correlation Process Correlation is an operation used in many applications in DSP. It is a measure of the degree to which two sequences are similar. Given two real-valued sequences x[n] and y[n] of finite energy, the crosscorrelation of x[n] and y[n] is a sequence given by
rx , y [l ] =

x[k ]y[k l ]
k =

The index l is called the shift or lag parameter. When y[n] = x[n], we are looking at autocorrelation :

rx , x [l ] =

x[k ]x[k l ]
k =

If we compare above with the convolution process, we can conclude that : rx,y[l] = y[l] * x[-l] = y[-l] * x[l], crosscorrelation and rx,x[l] = x[l] * x[-l], autocorrelation. Therefore, conv can be used to compute correlation.

Example : Recognition of signals (e.g. in radar systems). Let the original signal sequence be x[n] = { 3, 11, 7, 0, -1, 4, 2 } and it is corrupted by normally distributed noise sequence, w[n] of mean 0 and standard deviation of 1 : y[n] = x[n - 2] + w[n]. We will use correlation process to recognise the original signal and its delay.
x[n]
15 10 amplitude 5 0 -5 -2 0 n 2 amplitude 15 10 5 0 -5 0 2 n 4

y[n]

250 200 am plitude 150 100 50 0 -50 -4 -2 0 2 l 4 6 8

It is clear that the correlation exhibits a maximum value of 205 at l = 2. This implies that y[n] is similar to x[n] shifted by 2.

31

4/18/2012

Note: Convolution need flip of input /system . But Correlation no flip of input / system

32

Potrebbero piacerti anche