Top Banner

of 13

Dsp Lab Report-2 by L Govind ec

Apr 06, 2018

Download

Documents

Govind Reddy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    1/13

    DSP LAB REPORT-2

    1 | P a g e

    NIT CALICUT

    DSP LAB REPORT-2

    DEPARTMENT OF ELECTRONICS ENGINEERING

    NATIONAL INSTITUTE OF TECHNOLOGY CALICUT

    NIT CAMPUS PO, CALICUT

    KERALA, INDIA 673601

    By

    L Govind Reddy (M110117EC)

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    2/13

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    3/13

    DSP LAB REPORT-2

    3 | P a g e

    NIT CALICUT

    2. A unit impulse sequence ()is defined as

    () = 1 when n = 0

    0 when n 0

    Unit step signal:1. Continuous time unit step signal u(t), is defined as

    u(t) = 1 when t > 0= 0 when t < 0

    2. Discrete time unit step signal u(n), is defined as

    u(n) = 1 when n 0

    0 when n < 0

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    4/13

    DSP LAB REPORT-2

    4 | P a g e

    NIT CALICUT

    Unit Ramp signal:1. A continuous time unit ramp signal r(t) is defined as

    r(t) = t when t > 0= 0 when t < 0

    2. A discrete time unit ramp signal r(n) is defined as

    r(n) = n when n 0

    = 0 when n < 0

    1.3Even and odd signals?Even signal:

    A signal () is said to be even signal if

    () = ()

    Example:

    () =

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    5/13

    DSP LAB REPORT-2

    5 | P a g e

    NIT CALICUT

    Odd signal:

    A signal () is said to be odd signal if

    () = ()

    Example:

    () = sin ()

    1.4Linear convolution. Circular convolution?Linear convolution:

    1. Linear convolution of two signals () and () is defined as() = () () = ()( )

    The output of any Linear Time Invariant system is the convolution of input signal withthe impulse response of the system.

    2. Linear convolution of two sequences () and () is defined as() = () () = ()( )

    The output of any Discrete Time Invariant system is the convolution of input signal with

    the impulse response of the system.

    Circular convolution:

    The circular convolution of two sequences () and () is defined as

    () = () () = ()[( ) N] .

    Circular convolution is defined for finite length sequences (usually equal length sequences)

    1.5 Causal versus non-causal systems?Causal system:

    A system is said to be causal if the output () of the system at any time t = t0 depends onthe input () for t t0

    I.e. the output of the system depends on present and/or past values of the input not on

    future values of the inputExample:

    () = ( 2)Non Causal system:

    A system is said to be non-causal if its output depends on future values of the input.

    Example:

    () = ( + 3)

    N

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    6/13

    DSP LAB REPORT-2

    6 | P a g e

    NIT CALICUT

    1.6System stability?Stable system:

    A system is said to be stable if for any bounded value of input the output of system

    should be bounded.

    Example:

    () = ()

    2 Implement2.1 Generate two sinusoids with frequencies F0 = 1/8Hz and F1 = 7/8Hz. Sample both at Fs

    = 1Hz. Generate stem plots for each, with a different color for each. Plot the original

    continuous signals over the sampled one, again each color coded. What do you

    observe? Determine the sampling rate at which you can avoid a problem here? Repeat

    the procedure at this new sampling frequency. What do you observe?

    Program:%sampling both with frequency 1 Hz

    clc;

    clear all;

    f1=1/8;

    f2=-7/8;

    t1=0:.25:80/7;

    t2=0:.05:80/7;

    N1=0:1/1:80/7;

    N2=0:1/1:80/7;

    y1=sin(2*pi*f1*N1);

    y2=sin(2*pi*f2*N2);y1c=sin(2*pi*f1*t1);

    y2c=sin(2*pi*f2*t2);

    stem(N1,y1,'red');

    hold on;

    plot(t1,y1c,'green');

    hold on;

    stem(N2,y2,'black');hold on;

    plot(t2,y2c,'blue');

    hold on;

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    7/13

    DSP LAB REPORT-2

    7 | P a g e

    NIT CALICUT

    Output:

    Observation:

    Here the problem is, signal one is completely reconstructed from its samples since

    its frequency f1 is 1/8 and sampling frequency fs is 1 i.e. nearly 8 times signal frequency.

    But for the signal we cannot reconstruct the full signal from the sampled one because signalfrequency f2 is 7/8 and sampling frequency fs is 1 which is less than the 2f2 .

    So to avoid that problem we should take the sampling frequency at least twice the

    frequency of second signal (=1.75 Hz).

    Here in next program fs is taken as 3.5 Hz which equal to the four times of the second

    signal frequency

    Program:

    %sampling frequency fs=3.5 Hz

    clc;

    clear all;

    f1=1/8;

    f2=-7/8;

    t1=0:.25:80/7;

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    8/13

    DSP LAB REPORT-2

    8 | P a g e

    NIT CALICUT

    t2=0:.05:80/7;

    N1=0:1/1:80/7;

    N2=0:1/1.1:80/7;

    y1=sin(2*pi*f1*N1);

    y2=sin(2*pi*f2*N2);

    y1c=sin(2*pi*f1*t1);

    y2c=sin(2*pi*f2*t2);

    stem(N1,y1,'red');

    hold on;

    plot(t1,y1c,'green');

    hold on;

    stem(N2,y2,'black');

    hold on;

    plot(t2,y2c,'blue');

    hold on;

    Output:

    Here both signals can be reconstructed from there sampled ones.

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    9/13

    DSP LAB REPORT-2

    9 | P a g e

    NIT CALICUT

    2.2 Plot signal x (n) = [1 1 1 0 1 2 3 4], where x (0) = 0; Plot x (-n) and x (-n + 2). Obtain

    linear convolution with system h (n) = [1 2 1 -1], h (0) = 2; Show the output.

    Program:

    clc;

    clear all;

    close all;

    %x=[1 1 1 0 1 2 3 4];

    %h=[1 2 1 -1 ];

    x=input('enter x');

    h=input('enter y');

    [p q]=size(x);

    [r s]=size(h);

    p1=input('enter the indux range of x');

    r1=input('enter the indux range of y');

    %ploting x(n),x(-n),x(-n+2)

    n=p1(1):1:p1(2);

    subplot(2,2,1);stem(n,x);

    title('x(n)');

    subplot(2,2,2);

    stem(-n,x);

    title('x(-n)');

    subplot(2,2,3);

    stem(-n+2,x);

    title('x(-n+2)');

    %convolution....

    for m=1:s+q-1if m

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    10/13

    DSP LAB REPORT-2

    10 | P a g e

    NIT CALICUT

    Giving inputs to above function through command prompt:Command window:

    enter x[1 1 1 0 1 2 3 4]

    enter y[1 2 1 -1]

    enter range of x[-3 4] %since x(0)=0

    enter range of y[-1 2] %since h(0)=2

    Output:

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    11/13

    DSP LAB REPORT-2

    11 | P a g e

    NIT CALICUT

    2.3 Show stable and unstable conditions for the linear time invariant system h(n) = an

    u(n).

    Program:clc;

    clear all;

    close all;

    a1=2;

    a2=.5;

    %n will have only positve values because y(n)=a^n u(n),u(n)=0

    for n

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    12/13

    DSP LAB REPORT-2

    12 | P a g e

    NIT CALICUT

    3 Results and discussion3.1 Discuss sampling problem in implement 1. Can you give a theoretical explanation for

    the particular frequencies that come up? Would you be able to give a F2 for which this

    same sampling problem would occur at Fs?

    The problem encountered in program one is with sampling frequency fs(1 Hz), fs is

    greater than the 2f1(2*1/8 = 0.25 Hz) but it is not greater than 2f2 (2*7/8 = 1.75 Hz)so wecannot reconstruct the second signal from its sampled sequence.

    For fs = 1 Hz any signal which is having frequency greater than 0.5 Hz will face the sameproblem during reconstructing original signal from the sampled sequence because fs should

    be at least twice the signal frequency(from nyquist theorem).

    3.2 How would the result in implement 2 change if we were to change the origin point of(a) x (n)

    (b) h (n)1. For problem 2 initially

    (Value indicated in bold is origin)x(n) = [1 1 1 0 1 2 3 4]

    h(n) = [1 2 1 -1]And x(0) = 0 i.e. the index range of x is -3 to 4, h(0) = 2 i.e. index range of h is -1 to 2.

    The convolution of x(n) and h(n) is

    y(n) = [ 1 3 4 2 1 3 8 11 9 1 -4]

    Here y(0) = 1, i.e. the index range of y is -4 to 6.

    2. Now I will change the origin of x(n) and h(n)(Value indicated in bold is origin)

    x(n) = [1 1 1 0 1 2 3 4]h(n) = [1 2 1 -1]

    Here x(0) = 1 i.e. the index range of x is -4 to 3, h(0) = 1 i.e. index range of h is -2 to 1.The convolution of x(n) and h(n) is

    y(n) = [ 1 3 4 2 1 3 8 11 9 1 -4]

    Here y(0) = 8, i.e. the index range of y is -6 to 4.

    So if we change the origin of any sequence same values will repeat with differentindexes.

    3.3 How would the stability condition change if we were dealing with the systemh(n) = a

    nn

    0

    = bn n < 01. If n 0 then

    h(n) = an

    is stable if 0 < a 1 and h(n) is unstable if 0 < b 1.

  • 8/3/2019 Dsp Lab Report-2 by L Govind ec

    13/13

    DSP LAB REPORT-2

    13 | P a g e

    NIT CALICUT