+ All Categories
Home > Documents > My Dsp Lab Report

My Dsp Lab Report

Date post: 05-Apr-2018
Category:
Upload: seema-singh
View: 252 times
Download: 2 times
Share this document with a friend

of 21

Transcript
  • 7/31/2019 My Dsp Lab Report

    1/21

    Lab Report

    Of

    Digital Signal Processing

    Submitted in partial fulfillment of the requirement for the degree of

    Master of TechnologyIn

    VLSI Design

    Submitted To

    Ms. Sunita PrasadM. Tech (VLSI) Division,CDAC, NOIDA

    Submitted By

    Kumar Shekhar02511805211

    M. TECH. (VLSI) IInd Semester

    Centre for Development of Advanced Computing, NoidaAffiliated to

    Guru Gobind Singh Indraprastha UniversityKashmere Gate, Delhi 110006

  • 7/31/2019 My Dsp Lab Report

    2/21

    INDEX

    SL.NO. EXPERIMENT NAME DATE REAMRK

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

  • 7/31/2019 My Dsp Lab Report

    3/21

    Experiment -1

    AIM :- Write a MATLAB program to generate the basic signal sequences andplot them.

    (i) Unit Impulse Signal(ii) Unit Step Sequence(iii) Exponential Sequence(iv) Sinusoidal Sequence

    Program:-

    (i) x=[-3:1:5]y=[zeros(1,3),ones(1),zeros(1,5)]subplot(2,2,1)stem(x,y,'b')Xlabel('Time')

    Ylabel('Unit Sample Output')

    (ii) x=[-3:1:5]y=[zeros(1,3),ones(1),ones(1,5)]subplot(2,2,2)stem(x,y,'b')Xlabel('Time')Ylabel('Unit Step Output')

    (iii) x=[-5:1:5]y=exp(x)subplot(2,2,3)stem(x,y,'b')Xlabel('Time')Ylabel('Exponential Output')

    (iv) n=0:.2:2*pi;

    x= sin(n);subplot(1,1,1)stem(n,x);Xlabel('Time')Ylabel('Sinusoidal Output')

    Output at Command Window:-

  • 7/31/2019 My Dsp Lab Report

    4/21

    (i)

    -3 -2 -1 0 1 2 3 4 50

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    Time

    UnitSampleOutput

    (ii)

    -3 -2 -1 0 1 2 3 4 50

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    Time

    UnitStepOutput

  • 7/31/2019 My Dsp Lab Report

    5/21

    (iii)

    -5 -4 -3 -2 -1 0 1 2 3 4 50

    50

    100

    150

    Time

    ExponentialO

    utput

    (iv)

    0 1 2 3 4 5 6 7-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Time

    SinusoidalOutput

  • 7/31/2019 My Dsp Lab Report

    6/21

    Experiment No 2

    Aim :

    1. Let x(n) = u(n)-u(n-10). Decompose x(n) into even and odd decompositiousing MATLAB.2. Determine computation y(n)=x(n)*h(n) of the following sequences

    X[n]= [ 3, 11, 7, 0, -1, 4, 2] -3 n 3h[n]= [ 2, 3, 0, -5, 2, 1] -1 n 4

    3. Given the following Difference Equation

    y(n) - y(n-1) + 0.9 y(n-2) = x(n) ;

    (a)Calculate and plot the impulse response at n=-20,100.(b)Calculate and plot the unit step response at n=-20,100.(c)Is the system specified by h(n) stable?

    SOLUTION 1:

    %Funtion for Even & odd parts

    function[xe, xo, m]= evenodd(x,n)m = -fliplr(n);

    m1 = min([m,n]);m2 = max([m,n]); m = m1:m2;nm = n(1)-m(1); n1 = 1:length(n);x1 = zeros(1,length(m));x1(n1+nm) = x; x = x1;xe = 0.5*(x+fliplr(x));xo = 0.5*(x-fliplr(x));

    %Function Call

    n=[0:10]; x=stepseq(0,0,10)-stepseq(10,0,10);[xe,xo,m]=evenodd(x,n);figure(1);clfsubplot(2,2,1); stem(n,x); title('Rectangular pulse')xlabel('n');ylabel('x(n)');axis([-10,10,0,1.2])subplot(2,2,2);stem(m,xe);title('even part')xlabel('n');ylabel('xe(n)');axis([-10,10,0,1.2])subplot(2,2,4);stem(m,xo);title('odd part')xlabel('n');ylabel('xo(n)');axis([-10,10,-0.6,0.6])

  • 7/31/2019 My Dsp Lab Report

    7/21

    -10 -5 0 5 100

    0.5

    1

    Rectangular pulse

    n

    x(n)

    -10 -5 0 5 100

    0.5

    1

    even part

    n

    xe(n)

    -10 -5 0 5 10

    -0.5

    0

    0.5

    odd part

    n

    xo(n)

  • 7/31/2019 My Dsp Lab Report

    8/21

    Solution 2

    %Convolution of two sequences:

    x=[3,11,7,0,-1,4,2,0];h=[0,0,2,3,0,-5,2,1];y=conv(x,h);subplot(2,2,1);stem(x); title('x(n)');subplot(2,2,2);stem(h); title('h(n)');subplot(2,2,3);stem(y); title('y(n)');

    Output:

    0 2 4 6 8-5

    0

    5

    10

    15x(n)

    0 2 4 6 8-5

    0

    5h(n)

    0 5 10 15-100

    -50

    0

    50y(n)

  • 7/31/2019 My Dsp Lab Report

    9/21

    Solution 3a)

    clear all;close all;clc;disp('Difference Equation of a digital system');N=input('Desired Impulse response length = ');

    b=input('Coefficients of x[n] terms = ');a=input('Coefficients of y[n] terms = ');h=impz(b,a,N);disp('Impulse response of the system is h = ');disp(h);n=-20:1:100;figure(1);stem(n,h);xlabel('time index');ylabel('h[n]');title('Impulse response');

    Output:Difference Equation of a digital systemDesired Impulse response length = 100Coefficients of x[n] terms = 1Coefficients of y[n] terms = [1 -1 0.9]'Impulse response of the system is h =

    -20 0 20 40 60 80 100-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    time index

    h[n]

    Impulse response

  • 7/31/2019 My Dsp Lab Report

    10/21

    b)clear all;close all;clc;disp('Difference Equation of a digital system');N=input('Desired step response length = ');b=input('Coefficients of x[n] terms = ');a=input('Coefficients of y[n] terms = ');u=stepz(b,a,N);disp('Step response of the system is U = ');disp(u);n=-20:1:100;figure(1);stem(n,u);xlabel('time index');ylabel('U[n]');title('Step response');

    Output:Difference Equation of a digital systemDesired step response length = 121Coefficients of x[n] terms = 1Coefficients of y[n] terms = [1 -1 0.9]Step response of the system is U =

    -20 0 20 40 60 80 1000

    0.5

    1

    1.5

    2

    2.5

    time index

    U[n]

    Step response

  • 7/31/2019 My Dsp Lab Report

    11/21

    c)clc;clear all;close all;

    b=[0.9 -1 1];k=poly2rc(b);knew=fliplr(k);s = all(abs(knew));if(s==1)

    disp(' "Given system is a Stable System" ');else

    disp(' "Given system is an Unstable System" ');

    end

    Output:

    Given system is a Stable System

  • 7/31/2019 My Dsp Lab Report

    12/21

    Experiment No 3

    Aim :

    Point sequence x(n) defined as

    x(n) =[ 1 2 3 4 5 6 6 5 4 3 2 1]

    a) Determine DFT X(k) of x(n). Plot (using stem) its magnitude and phase ancalculate manually. Show both are same.b) Plot the magnitude and phase of DTFT X(e^jw) of x(n) using MATLABc)Verify that the above DFT is the sampled version of X(e^jw). It might behelpful to combine the above two plots in a graph using hold function.Solution:a)DFT:::::

    xn= [1 2 3 4 5 6 6 5 4 3 2 1];N = 12;n = [0:1:N-1]; k = [0:1:N-1];WN = exp(-j*2*pi/N); nk = n'*k;WNnk = WN .^nk; Xk= xn*WNnk;magXk = abs(Xk);angXk =angle(Xk);figure;subplot(2,2,1);stem(magXk);gridxlabel('frequency in units of pi');ylabel('|X|')subplot(2,1,2);stem(angXk);gridxlabel('frequency in units of pi');ylabel('radians/pi')

  • 7/31/2019 My Dsp Lab Report

    13/21

    output:

    0 5 10 150

    20

    40

    60

    frequency in units of pi

    |X

    |

    0 2 4 6 8 10 12-3

    -2

    -1

    0

    1

    2

    frequency in units of pi

    radians/pi

    To calculate manually we have to compute DFT Coefficents one by one.

    X(k)=

    [42 -13.9 -3.73i 0 -1- 1i 0 0.0718-0.2679i 0 -0.0718+0.2679i 0 -1+1i -13.9282+3.7321i ]

    From above coefficients we analyze that results are similar to our calculatedresults.

  • 7/31/2019 My Dsp Lab Report

    14/21

    b)N=12; x = [1 2 3 4 5 6 6 5 4 3 2 1];n = [0:1:N-1]; k = [0:1:N-1];w = (pi/12)*k;X = x * (exp(-j*pi/12)) .^ (n'*k);magX = abs(X); angX =angle(X);subplot(2,2,1); plot(w/pi,magX);gridxlabel('frequency in units of pi');ylabel('|X|')subplot(2,1,2); plot(w/pi,angX/pi);gridxlabel('frequency in units of pi');ylabel('radians/pi')

    0 0.5 10

    20

    40

    60

    frequency in units of pi

    |X|

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    frequency in units of pi

    radians/pi

  • 7/31/2019 My Dsp Lab Report

    15/21

    c)using hold function we compare the graphs and find that DTFT sam-ples are DFT coefficients themselves

    0 0 . 5 10

    2 0

    4 0

    6 0

    f r e q u e n c y i n u n i t s o f p i

    |X

    |

    0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1- 1

    - 0 . 5

    0

    0 . 5

    1

    f r e q u e n c y i n u n i t s o f p i

    radians

    /pi

    0 5 1 0 1 50

    2 0

    4 0

    6 0

    f r e q u e n c y i n u n i t s o f p i

    |X

    |

    0 2 4 6 8 1 0 1 2- 3

    - 2

    - 1

    0

    1

    2

    f r e q u e n c y i n u n i t s o f p i

    radians/pi

  • 7/31/2019 My Dsp Lab Report

    16/21

    Experiment No 4

    Aim :

    Given a causal system y(n) = 0.9y(n-1) + x(n)

    a)Find H(z) and sketch the pole zero plot in MATLAB

    b)Plot |H(e^jw)| & H(e^jw)Solution

    a) Difference equation can be put in the formy(n) - 0.9y(n-1) = x(n)

    The system transfer fn from the difference equation is given as

    H(z) = 1/(1 0.9 z-1); |z|>0.9

    There is one pole at 0.9 and a zero at origin. We will use zplane fn to

    represent it in MATLAB

    b = [ 1 , 0 ]; a = [ 1 , - 0.9 ];zplane(b,a)

    -1 -0.5 0 0.5 1

    -1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Real Part

    ImaginaryPart

  • 7/31/2019 My Dsp Lab Report

    17/21

    b) Now for determining the frequency response we use freqz fn in MAT-LAB.

    [H,w] = freqz(b,a,100);magH = abs(H) ; phaH = angle(H);

    subplot(2,1,1); plot(w/pi,magH);gridxlabel(frequency in pi units); ylabel(Magnitude);title(Magnitude Response)subplot(2,1,2); plot(w/pi,phaH/pi); gridxlabel(frequency in pi units); ylabel(Phase in pi units);title(Phase Response)

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

    5

    10

    15

    frequency in pi units

    Magnitud

    e

    Magnitude Response

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-0.4

    -0.3

    -0.2

    -0.1

    0

    frequency in pi units

    Phaseinpiunits

    Phase Response

    Experiment No 5

  • 7/31/2019 My Dsp Lab Report

    18/21

    Aim :

    A causal LTI system is described by the following differential equation.y(n) = 0.81y(n-2) + x(n) x(n-2)Determinea)System fn H(z)b)Unit impulse response h(n).

    c) Unit step response v(n),that is, response to the unit step u(n), andd)the frequency response function H(e^jw), and plot its magnitude and

    phase over 0 w

    Solution:a)

    Its a causal system , the ROC will be outside of a circle with radiusequal to largest pole magnitude.

    Taking the z-transform of both sides and then solving for Y(z)/X(z) we get

    H(z) = (1 z-2)/(1 0.81z-2) = (1 z-2)/(1+0.9z-1)*(1-0.9z-1)b)

    Using MATLAB for partial fn expansionb = [1, 0, -1]; a = [1, 0, -0.81];[R, p, C] = residue(b,a)

    Output:R =

    -0.1173-0.1173

    p =

    -0.9000

    0.9000

    C =

    1.2346So the system function is given by

  • 7/31/2019 My Dsp Lab Report

    19/21

    H(z) = 1.2346 0.1173 * 1/(1 + 0.9z-1) - 0. 1173 * 1/(1 - 0.9z-1), |z| >0.9

    Taking inverse Z transform of above we geth(n) = 1.2346 (n) 0.1173{1 + (-1)^n}(0.9^n)u(n)

    c) we know [ u(n) ] = 1/ (1-z-1), |z|>1

    V(z) = H(z)U(z) =[(1 + z-1)(1 - z-1)/ (1 + 0.9z-1)(1 - 0.9z-1)]* [1/ (1-z-1)]

    = (1 + z-1)/ (1 + 0.9z-1)(1 - 0.9z-1) , |z| > 0.9

    V(z) = 1.0556* 1/(1 - 0.9z-1) - 0.0556*(1 + 0.9z-1) , |z| > 0.9

    Using inverse Z transform we getv(n) = [1.0556(0.9)^n - 0.0556 (-0.9)^n ] u(n)

    d) Substituting z= e^jw in H(z) we getH(z) = (1 e^-j2w)/(1 0.81e^-j2w)

    Using MATLABw = [0:1:500]*pi/500;

    H = freqz(b,a,w);magH = abs (H); phaH = angle (H);subplot(2,1,1); plot(w/pi, magH); gridxlabel(frequency in pi units); ylabel(Magnitude);title(Magnitude Response)subplot(2,1,2); plot(w/pi,phaH/pi); gridxlabel(frequency in pi units); ylabel(Phase in pi units);title(Phase Response)

  • 7/31/2019 My Dsp Lab Report

    20/21

    0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 10

    0 . 2

    0 . 4

    0 . 6

    0 . 8

    1

    1 . 2

    1 . 4

    f r e q u e n c y i n u n i t s o f p i

    |X

    |

    M a g n i t u d e P a r t

    0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1- 0 . 5

    0

    0 . 5

    f r e q u e n c y i n u n i t s o f p i

    radians/pi

    A n g l e P a r t

    Experiment No 5

  • 7/31/2019 My Dsp Lab Report

    21/21

    Aim :

    Given the following Difference equation .

    y(n) = x(n) + 2 x(n-1) 0.2 y(n-2)

    Implement in simulink

    Solution:

    To create a new model:1. If Simulink is not running, enter simulink in the MATLAB Command Win-

    dow to open the Simulink Library Browser.2. Select File > New > Model in the Simulink Library Browser to create a

    new model.The software opens an empty model window.To construct a model, we first copy blocks from the Simulink Library Brows-er to the model window. To create the required model , we need 8 blocks .These are 2 gain blocks, sum, output(scope),input and three unit delays.

    By connecting as shown in figure below we realize our required system.


Recommended