2b manipulation of signal

Upload: kalaiyarasan-veeramuthu

Post on 03-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 2b Manipulation of Signal

    1/32

    4/18/

    Manipulate

    Sampled Signal

    Lecture 2a

  • 7/28/2019 2b Manipulation of Signal

    2/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    3/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    4/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    5/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    6/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    7/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    8/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    9/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    10/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    11/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    12/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    13/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    14/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    15/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    16/32

    4/18/

  • 7/28/2019 2b Manipulation of Signal

    17/32

    4/18/

    %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);

    Type the following Matlab commands generate the following graphs:

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

    0 2 4 6 8 10 1 2 1 4 1 6 1 8 20-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    0 2 4 6 8 10 1 2 1 4 16 1 8 2 0-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 2 4 6 8 10 1 2 1 4 16 1 8 2 0-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 2 4 6 8 10 1 2 1 4 16 1 8 20-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

  • 7/28/2019 2b Manipulation of Signal

    18/32

    4/18/

    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]

    w2[n]

    w1[n] =x[n]y[n]modulation / product

    w2[n] =x[n] +y[n]addition

    x[n] w3[n] x[n] w4[n]A D

    x[n] w5[n]D-1

    Time reversal : w6 =x[-n], a time-reversed version ofx[-n].

    N-delay : w7 =x[n-N], ifNis positive.

    IfNis negative it becomes an advance of the sequence

    w3[n] =Ax[n]

    multiplication

    w4[n] =x[n - 1]

    unit delay

    w5[n] =x[n + 1]

    unit advance

  • 7/28/2019 2b Manipulation of Signal

    19/32

    4/18/

    Modulation examples :

    To transform a sequence with low-frequency sinusoidalcomponents to a sequence with high-frequency components.

    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} whereA = 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 } whereN= 3.U1f19.m

    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 thatx[n] has been appended with two zeros to make it as

    sequence of length of 5 in order to perform the above operations.

    D D D

    1 2 3 4

    +

    y[n]

    x[n-1] x[n-2] x[n-3]x[n]

    Example :

    What isy[n], the output of the

    discrete system, in terms ofx[n] ?

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

    3x[n-2] + 4x[n-3]

  • 7/28/2019 2b Manipulation of Signal

    20/32

    4/18/

    What isy[n], the output of the discrete system ?

    y[n] = b0x[n] + b1x[n-1] + b2x[n-2] + a0y[n-1] + a1y[n-2]

    y[n]+

    b0

    D

    D

    b1

    b2

    D

    D

    a0

    a1

    y[n-1]

    y[n-2]

    x[n-1]

    x[n-2]

    x[n]

    System Impulse Response

    [n] h[n]

    ?

    x[n]

    y[n] =x[n] h[n]

    Convolution:

    n-1 1 2 3 4 5 6 7

    1

    -2-3 n-1 1 2 3 4 5 6 7

    1

    -2-3

    23

    n-1 1 2 3 5 6 7-2-3

  • 7/28/2019 2b Manipulation of Signal

    21/32

    4/18/

    An LTI discrete-time system is completely defined by its impulse

    response i.e. knowing the impulse response, we can compute theoutput 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 bey[n] = 0.5 h[n + 2] + 1.5 h[n - 1] - h[n - 2] + h[n - 4] + 0.75 h[n - 6]

    Input-Output Relationship

    We can generalise the above result for an arbitrary input sequence

    x[n] that can be expressed as

    [ ] [ ] [ ]

    =

    =

    k

    knhkxny

    or alternatively, [ ] [ ] [ ]

    =

    =

    k

    khknxny

    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

    outputy[n] due to any inputx[n].

  • 7/28/2019 2b Manipulation of Signal

    22/32

    4/18/

    The above two equations are called the convolution sum of the

    sequencesx[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 discrete-

    time system bex[n] = [n + 1] + 2 [n] + 3 [n - 1] - [n - 2] and

    h[n] = [n] - [n - 1] + 2 [n - 2]. Determine the output,y[n].

    ConvolutionFormula:

    Methods for Convolution Graphical / sliding method

    Frequency domain evaluation

    Matlab: y = conv(x, h)

    Analytical evaluation

    Graphical Convolution

  • 7/28/2019 2b Manipulation of Signal

    23/32

    4/18/

    Convolution by Graphical Method

    Convolution by Graphical Method (cont)

  • 7/28/2019 2b Manipulation of Signal

    24/32

    4/18/

    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]

    y[0] = . + 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 +

    x[5] 0 + . = 1.3679..

    Graphical Convolution

    [1]

  • 7/28/2019 2b Manipulation of Signal

    25/32

    4/18/

    Convolution by Sliding Method

    For simple sequences it is possible to determine the output of

    convolution by reversing one of the two convolving sequences andslide it against the other fixed sequence.

    The sum of the resultant sequence for every slide step, n is

    equivalent toy[n].

    See the diagrams in the next pages for the sliding technique.

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0

    0 0 0 0 0 0 0 0 0 1 -1 2 0 0 0 0 0 0 0

    x[k]

    h[k] =

    0 0 0 0 0 2 -1 1 0 0 0 0 0 0 0 0 0 0 0h[-2-k]

    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0y[-2] =

    =

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k]

    0 0 0 0 0 0 2 -1 1 0 0 0 0 0 0 0 0 0 0h[-1-k]

    0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0y[-1] =

    =

    = 0

    = 1

    0 0 0 0 0 2 -1 1 0 0 0 0 0 0 0 0 0 0 0h[-2-k]

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k] =

    k= 0

    Let

    Let

  • 7/28/2019 2b Manipulation of Signal

    26/32

    4/18/

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k]

    0 0 0 0 0 0 0 2 -1 1 0 0 0 0 0 0 0 0 0h[-k]

    0 0 0 0 0 0 0 0 -1 2 0 0 0 0 0 0 0 0 0y[0] =

    =

    = 1

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k]

    0 0 0 0 0 0 0 0 2 -1 1 0 0 0 0 0 0 0 0h[1-k]

    0 0 0 0 0 0 0 0 2 -2 3 0 0 0 0 0 0 0 0y[1] =

    =

    = 3

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k]

    0 0 0 0 0 0 0 0 0 2 -1 1 0 0 0 0 0 0 0h[2-k]

    0 0 0 0 0 0 0 0 0 4 -3 -1 0 0 0 0 0 0 0y[2] =

    =

    = 0

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k]

    0 0 0 0 0 0 0 0 0 0 2 -1 1 0 0 0 0 0 0h[3-k]

    0 0 0 0 0 0 0 0 0 0 6 1 0 0 0 0 0 0 0y[4] =

    =

    = 7

    0 0 0 0 0 0 0 0 1 2 3 -1 0 0 0 0 0 0 0x[k]

    0 0 0 0 0 0 0 0 0 0 0 2 -1 1 0 0 0 0 0h[4-k]

    0 0 0 0 0 0 0 0 0 0 0 -2 0 0 0 0 0 0 0y[5] =

    =

    = -2

    0 0 0 0 0 0 0 0 1 1 3 0 7 -2 0 0 0 0 0y[n]

    n (+ve)

    [4]

    [3]

  • 7/28/2019 2b Manipulation of Signal

    27/32

    4/18/

    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 outputy[n] betweenx[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 lengthsNandMalwaysresults in an output sequence of lengthN+M- 1.

    Convolution in Matlab

    However, conv does not provide or accept any timing information.Example : Find the convolution outputy[n] betweenx[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 fory[n] : ny-s = -3 + -1 = -4.

    End point fory[n] : ny-e = 3 + 4 = 7

    y =

    6 31 47 6 -51 -5 41 18 -22 -3 8 2

    n = 0

  • 7/28/2019 2b Manipulation of Signal

    28/32

    4/18/

    Example : Determine the outputy[n] for an LTI system with input

    ofx[n] = u[n] - u[n-10] and h[n] = 0.9n u[n].

    To generatey[n] using Matlab we need to define finite-lengthsequences. Assume thatx[n] and h[n] are defined for 0 n < 30

    0 5 10 15 20 25

    0

    0.5

    1

    n

    amplitude

    0 5 10 15 20 25

    0

    0.5

    1

    n

    amplitude

    0 10 20 30 40 50

    0

    2

    4

    6

    n

    amplitude

    Starting point is 0 while end

    point is 29+29 = 58.

    U2f7.m

    x[n]

    h[n]

    y[n]

    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.

    -2 0 2 4

    -2

    0

    2

    4

    n

    amplitude

    -5 0 5 10

    -2

    -1

    0

    1

    2

    3

    n

    amplitude

    -5 0 5 10 15

    -10

    -5

    0

    5

    10

    n

    amplitude

    U2f7a.m

    x[n]

    h[n]

    y[n]

  • 7/28/2019 2b Manipulation of Signal

    29/32

    4/18/

    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); nye = nx(length(x)) + nh(length(h));

    ny = [nyb:nye];

    y = conv(x,h);

    A new function conv_mhas been defined and used here :

    The function take into account the timing information of the input

    sequences expressed in the form of a matrix : [ starting value ofn :

    ending value ofn ]. Output sequence is returned together with

    timing information matrix.

    - Assume thatx[n], h[n] andz[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 withx[n]

    x[n] * [n - k] =x[n k]

    Properties of Convolution

  • 7/28/2019 2b Manipulation of Signal

    30/32

    4/18/

    There are two widely used schemes for developing complex LTI

    discrete-time systems from simple LTI discrete-time systems.

    h1[n] h2[n] h2[n] h1[n]

    h1[n] * h2[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]

    Simple Interconnection Schemes

    Cascade Connection

    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]

    h2[n]

    h1[n] + h2[n]+

  • 7/28/2019 2b Manipulation of Signal

    31/32

    4/18/

    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 sequencesx[n] andy[n] of finite energy,

    the crosscorrelation ofx[n] andy[n] is a sequence given by

    The index l is called the shift or lag parameter. Wheny[n] =x[n],

    we are looking at autocorrelation :

    If we compare above with the convolution process, we can

    conclude that : rx,y[l] =y[l] *x[-l] =y[-l] *x[l], crosscorrelationand rx,x[l] =x[l] *x[-l], autocorrelation. Therefore, conv can be

    used to compute correlation.

    [ ] [ ] [ ]

    =

    =

    k

    yx lkykxlr ,

    [ ] [ ] [ ]

    =

    =

    k

    xx lkxkxlr ,

    Correlation Process

    Example : Recognition of signals (e.g. in radar systems). Let the

    original signal sequence bex[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.

    -2 0 2

    -5

    0

    5

    10

    15

    n

    amplitude

    0 2 4

    -5

    0

    5

    10

    15

    n

    amplitude

    -4 -2 0 2 4 6 8

    -50

    0

    50

    100

    150

    200

    250

    l

    amplitude

    It is clear that the correlation

    exhibits a maximum value of

    205 at l = 2. This implies

    thaty[n] is similar tox[n]

    shifted by 2.

    x[n] y[n]

  • 7/28/2019 2b Manipulation of Signal

    32/32

    4/18/

    Note:Convolution need flip of input /system .

    But Correlation no flip of input / system