Dsp Record

Post on 06-Apr-2018

219 views 0 download

Transcript of Dsp Record

  • 8/3/2019 Dsp Record

    1/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    1. GENERATIONOF BASIC SIGNALS

    ( unit impulse, exponential, unit step, ramp )

    AIM : To generate the Basic Signals like unit impulse, step, ramp, and exponential.

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : In this program basic signals like unit impulse, unit step,

    ramp, and exponential signals are to be generated based on the following definitions.

    1. Unit impulse signal: This signal is having unit amplitude only at origin and else

    where the amplitude zero. It is denoted by (t).

    2. Unit step signal: This signal is having unit amplitude for all the positive values of

    time axis and else where the amplitude zero. It is denoted by u (t). The sequence is

    denoted by u[n].

    3. Ramp signal: This signal is having amplitude values linearly increasing same as

    the time axis values from origin to all the positive values and else where theamplitude zero. It is denoted by r(t). The sequence is denoted by r[n].

    4. Exponential signal: This signal is having the amplitudes exponentially increasing

    with time. This is a plot ofeat.Where e denotes exponential function, a is aninteger and t is the time scale.

    PROGRAM :

    %Generation of various signals: impulse, exponential, step, ramp.

    clc;

    clear all;

    clear all;

    %impulse sequence

    t=-2:1:2;

    y1=[zeros(1,2) 1 zeros(1,2)];

    subplot (2,2,1);

    stem(t,y1);

    grid

    title ('Impulse Response');

    xlabel ('no. of samples :n-->');

    ylabel ('--> Amplitude');

    %Exponential Sequence

    n=input('enter the length of Exponential Sequence');

    t=0:1:n;

    a=input('Enter "a" value');

    y2=exp(a*t);

    subplot(2,2,2);

    1

  • 8/3/2019 Dsp Record

    2/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    stem(t,y2);

    grid

    title ('Exponential Sequence');

    xlabel ('no. of samples :n-->');

    ylabel ('--> Amplitude');

    %Step Sequence

    s=input ('enter the length of step sequence');

    t=-s:1:s;

    y3=[zeros(1,s) ones(1,1) ones(1,s)];

    subplot(2,2,3);

    stem(t,y3);

    grid

    title ('Step Sequence');

    xlabel ('no. of samples :n-->');

    ylabel ('--> Amplitude');

    %Ramp Sequence

    x=input ('enter the length of Ramp sequence');

    t=0:x;subplot(2,2,4);

    stem(t,t);

    grid

    title ('Ramp Response');

    xlabel ('no. of samples :n-->');

    ylabel ('--> Amplitude');

    OUPUTS:

    enter the length of Exponential Sequence: 5

    Enter "a" value :2

    enter the length of step sequence: 5

    enter the length of Ramp sequence: 6

    2

  • 8/3/2019 Dsp Record

    3/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPHS :

    -2 -1 0 1 20

    0.5

    1Impulse Response

    no. of samples :n-->

    -->

    Amplitude

    0 2 4 60

    1

    2

    3x 10

    4Exponential Sequence

    no. of samples :n-->

    -->

    Amplitude

    -5 0 50

    0.5

    1Step Sequence

    no. of samples :n-->

    -->

    Amplitud

    e

    0 2 4 60

    2

    4

    6Ramp Response

    no. of samples :n-->

    -->

    Amplitud

    e

    INFERENCE : In the generation of the basic signals we have defined the signals alongtime and amplitude axes for unit impulse, step, ramp and exponential signals and plotted

    the graphs. For different values the graphs are plotted.

    RESULT : The basic signals like unit impulse , unit step, ramp and exponential signals

    are generated and the waveforms are plotted.

    3

  • 8/3/2019 Dsp Record

    4/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    2. GENERATION OF BASIC SIGNALS

    ( Sinusoidal signal )

    AIM : To Generate sinusoidal signal of frequency f Hz and phase phi

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : A sinusoidal signal is a continuous signal whoseamplitude varies between two fixed values on the positive and negative amplitude axes.

    This is a plotted as a function of frequency, time and phase for different values. This signal

    is represented as y(t)=A sin ( 2ft+ ). Where A is amplitude, f is the frequency, t is time

    and is phase.

    PROGRAM :

    % Generation of sinusoidal signal of f Hz and phase phi

    clc;

    clear all;

    close all;

    A=input('Enter the amplitude of the sinusoidal signal= ');

    f = input('Enter the frequency of the sinusoid sequence f = ');

    phi = input('Enter the phase of the sinusoid sequence phi = ');

    fs = input('Enter the sampling frequency fs = ');

    T = input('Enter the duration of the sequence T = ');

    dt = 1/fs;

    t = 0:dt:T;

    y = A*sin(2*pi*f*t + phi);

    plot(t,y);

    title('Sinusoidal signal','fontsize',12);

    xlabel('t -->');

    ylabel('Amplitude -->');

    OUTPUTS:Enter the amplitude of the sinusoidal signal= 3

    Enter the frequency of the sinusoid sequence f = 4

    Enter the phase of the sinusoid sequence phi = 10

    Enter the sampling frequency fs = 1000

    Enter the duration of the sequence T = 2

    4

  • 8/3/2019 Dsp Record

    5/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPHS :

    0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-3

    -2

    -1

    0

    1

    2

    3Sinusoidal signal

    t -->

    Amplitude-->

    INFERENCE : The frequency f indicates the no. of cycles in one second i.e., in this

    program 4 cycles in one second as f = 4. Similarly duration indicates the total signal which

    is to be displayed, here duration is 2, means from 0 to 2 sec. the signal is plotted.

    RESULT : For a particular frequency f Hz and phase phi, the sinusoidal signal is generated

    and plotted.

    5

  • 8/3/2019 Dsp Record

    6/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    3. BASIC OPERATIONS ON SIGNALS

    ( Shifting, Folding, Multiplication and Addition)

    AIM : To perform different operations like shifting, addition, folding, multiplication and

    shifting of basic signals.

    SOFTWARE REQUIRED : MAT LAB 7.0PROGRAM DESCRIPTION : In this program the basic operations like shifting, addition,

    folding, multiplication and shifting is operated on basic signals like impulse, step, ramp,

    exponential.

    PROGRAM :

    % Basic operations on impulse signal: shifting operationclc;

    clear all;

    clear all;

    %impulse sequence

    t=-3:1:3;

    y1=[zeros(1,3) 1 zeros(1,3)];

    subplot (3,1,1);

    stem(t,y1);

    grid;

    title ('Impulse Response');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    %impulse sequence shifted right by one location

    t=-3:1:3;

    y2=[zeros(1,4) 1 zeros(1,2)];

    subplot (3,1,2);

    stem(t,y2);

    grid;title ('Impulse Response shifted right by one location');

    xlabel ('time-->');

    ylabel ('Amplitude-->');

    %impulse sequence shifted left by two location

    t=-3:1:3;

    y3=[zeros(1,1) 1 zeros(1,5)];

    subplot (3,1,3);

    stem(t,y3);

    grid;

    title ('Impulse Response shifted left by two locations');

    xlabel ('time-->');

    ylabel ('Amplitude-->');

    6

  • 8/3/2019 Dsp Record

    7/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPHS:

    -3 -2 -1 0 1 2 30

    0.5

    1Impulse Response

    time -->

    -->

    Am

    plitude

    -3 -2 -1 0 1 2 30

    0.5

    1Impulse Response shifted right by one location

    time-->

    Amplitude-->

    -3 -2 -1 0 1 2 30

    0.5

    1Impulse Response shifted left by two locations

    time-->

    Amplitude-->

    %Basic operations on step signal: folding operationclc;clear all;

    clear all;

    %Step Sequence

    s=input ('enter the length of step sequence');

    t=-s:1:s;

    y1=[zeros(1,s) ones(1,1) ones(1,s)];

    subplot(1,2,1);

    stem(t,y1);

    grid

    title ('Step Sequence');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    %Step Sequence after folding

    y2=[ones(1,s) ones(1,1) zeros(1,s)];

    subplot(1,2,2);

    stem(t,y2);

    grid

    title ('Step Sequence after folding');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    7

  • 8/3/2019 Dsp Record

    8/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    OUPUTS:enter the length of step sequence: 5

    GRAPHS:

    -5 0 50

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1Step Sequence

    time -->

    -->

    Amplitude

    -5 0 50

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1Step Sequence after folding

    time -->

    -->

    Amplitude

    %Basic operations on signals: folding operation on ramp signalclc;

    clear all;

    clear all;

    %Ramp Sequence

    x=input('enter the length of the ramp sequence:')

    t=0:xsubplot(2,1,1)

    stem(t,t)

    grid

    title ('Ramp Response');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    %Ramp Sequence after folding

    t=-x:0

    8

  • 8/3/2019 Dsp Record

    9/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    y=-t

    subplot(2,1,2)

    stem(t,y)

    grid

    title ('Ramp Response after folding');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    OUTPUTS:enter the length of the ramp sequence:5

    x = 5t = 0 1 2 3 4 5

    t = -5 -4 -3 -2 -1 0

    y = 5 4 3 2 1 0

    GRAPHS:

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

    2

    4

    6

    Ramp Response

    time -->

    -->

    Amplitude

    -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 00

    2

    4

    6Ramp Response after folding

    time -->

    -->

    Amplitude

    %Basic operations on signals: folding operation on exponential signal

    clc;clear all;

    clear all;

    %Exponential Sequence

    n=input('enter the length of Exponential Sequence:');

    t=0:1:n;

    a=input('Enter "a" value:');

    y=exp(a*t);

    9

  • 8/3/2019 Dsp Record

    10/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    subplot(2,1,1);

    stem(t,y);

    grid

    title ('Exponential Sequence');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    %Exponential Sequence after folding

    subplot(2,1,2)

    stem(-t,y)

    grid

    title ('Exponential Sequence');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    OUTPUTS:enter the length of Exponential Sequence: 5

    Enter "a" value: 0.8

    GRAPHS:

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

    20

    40

    60Exponential Sequence

    time -->

    -->

    Amplitude

    -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 00

    20

    40

    60Exponential Sequence

    time -->

    -->

    Amplitude

    INFERENCE : In this program the shifting operation is performed n impulase signal,folding operation is performed on step, ramp, and exponential signals.

    RESULT : Different operations like shifting, addition, folding, multiplication and shifting

    of basic signals like impulse, step, ramp, and exponential is performed and the graphs areplotted.

    10

  • 8/3/2019 Dsp Record

    11/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    4. FINDING THE FFT OF DIFFERENT SIGNALS

    AIM : To find the FFT of different signals like impulse, step, ramp and exponential.

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : In this program using the command FFT for impulse, step,

    ramp and exponential sequences the FFT is generated. In the process of finding the FFT the

    length of the FFT is taken as N. The FFT consists of two parts: MAGNITUDE PLOT andPHASE PLOT. The magnitude plot is the absolute value of magnitude versus the samples

    and the phase plot is the phase angle versus the samples.

    PROGRAM :

    % FFT of the impulse sequence : magnitude and phase responseclc;

    clear all;

    close all;%impulse sequence

    t=-2:1:2;

    y=[zeros(1,2) 1 zeros(1,2)];

    subplot (3,1,1);

    stem(t,y);

    grid;

    input('y=');

    disp(y);

    title ('Impulse Response');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    xn=y;

    N=input('enter the length of the FFT sequence: ');xk=fft(xn,N);

    magxk=abs(xk);

    angxk=angle(xk);

    k=0:N-1;

    subplot(3,1,2);

    stem(k,magxk);

    grid;

    xlabel('k');

    ylabel('|x(k)|');

    subplot(3,1,3);

    stem(k,angxk);

    disp(xk);

    grid;

    xlabel('k');ylabel('arg(x(k))');

    OUTPUTS:

    y= 0 0 1 0 0

    enter the length of the FFT sequence: 10

    11

  • 8/3/2019 Dsp Record

    12/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i

    1.0000 0.3090 - 0.9511i -0.8090 - 0.5878i -0.8090 + 0.5878i 0.3090 + 0.9511i

    GRAPHS:

    -2 -1.5 -1 -0.5 0 0.5 1 1.5 20

    0.5

    1ImpulseResponse

    time-->

    -->Amplitude

    0 1 2 3 4 5 6 7 8 90

    0.5

    1

    k

    |x(k)|

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

    0

    5

    k

    arg(x(k))

    % FFT of the step sequence : magnitude and phase responseclc;

    clear all;close all;

    %Step Sequence

    s=input ('enter the length of step sequence');

    t=-s:1:s;

    y=[zeros(1,s) ones(1,1) ones(1,s)];

    subplot(3,1,1);

    stem(t,y);

    grid

    input('y=');

    disp(y);

    title ('Step Sequence');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    xn=y;N=input('enter the length of the FFT sequence: ');

    xk=fft(xn,N);

    magxk=abs(xk);

    angxk=angle(xk);

    k=0:N-1;

    subplot(3,1,2);

    stem(k,magxk);

    grid

    12

  • 8/3/2019 Dsp Record

    13/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    xlabel('k');

    ylabel('|x(k)|');

    subplot(3,1,3);

    stem(k,angxk);

    disp(xk);

    grid

    xlabel('k');

    ylabel('arg(x(k))');

    OUTPUTS:enter the length of step sequence: 5

    y= 0 0 0 0 0 1 1 1 1 1 1

    enter the length of the FFT sequence: 10

    5.0000 -1.0000 + 3.0777i 0 -1.0000 + 0.7265i 0 -1.0000 0-1.0000 - 0.7265i 0 -1.0000 - 3.0777i

    GRAPHS:

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

    0.5

    1Step Sequence

    time -->

    -->

    Amplitude

    0 1 2 3 4 5 6 7 8 90

    5

    k

    |x

    (k)|

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

    0

    5

    k

    arg(x(k))

    % FFT of the Ramp sequence: magnitude and phase response

    clc;

    clear all;

    close all;

    %Ramp Sequence

    s=input ('enter the length of Ramp sequence: ');

    t=0:s;

    y=t

    subplot(3,1,1);

    13

  • 8/3/2019 Dsp Record

    14/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    stem(t,y);

    grid

    input('y=');

    disp(y);

    title ('ramp Sequence');

    xlabel ('time -->');

    ylabel ('--> Amplitude');

    xn=y;

    N=input('enter the legth of the FFT sequence: ');

    xk=fft(xn,N);

    magxk=abs(xk);

    angxk=angle(xk);

    k=0:N-1;

    subplot(3,1,2);

    stem(k,magxk);

    grid

    xlabel('k');

    ylabel('|x(k)|');

    subplot(3,1,3);

    stem(k,angxk);

    disp(xk);grid

    xlabel('k');

    ylabel('arg(x(k))');

    OUTPUTS:enter the length of Ramp sequence: 5

    y = 0 1 2 3 4 5

    enter the length of the FFT sequence: 10

    15.0000 -7.7361 - 7.6942i 2.5000 + 3.4410i -3.2639 - 1.8164i 2.5000 + 0.8123i

    -3.0000 2.5000 - 0.8123i -3.2639 + 1.8164i 2.5000 - 3.4410i -7.7361 + 7.6942i

    GRAPHS:

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

    5rampSequence

    time-->

    -->Amplitud

    0 1 2 3 4 5 6 7 8 90

    10

    20

    k

    |x(k)|

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

    0

    5

    k

    arg(x(k))

    14

  • 8/3/2019 Dsp Record

    15/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    % FFT of the Exponential Sequence : magnitude and phase response

    clc;

    clear all;

    close all;

    %exponential sequence

    n=input('enter the length of exponential sequence: ');t=0:1:n;

    a=input('enter "a" value: ');

    y=exp(a*t);

    input('y=')

    disp(y);

    subplot(3,1,1);

    stem(t,y);

    grid;

    title('exponential response');

    xlabel('time');

    ylabel('amplitude');

    disp(y);

    xn=y;

    N=input('enter the length of the FFT sequence: ');

    xk=fft(xn,N);

    magxk=abs(xk);

    angxk=angle(xk);

    k=0:N-1;

    subplot(3,1,2);

    stem(k,magxk);

    grid;

    xlabel('k');

    ylabel('|x(k)|');

    subplot(3,1,3);

    stem(k,angxk);

    grid;

    disp(xk);xlabel('k');

    ylabel('arg(x(k))');

    OUTPUTS:enter the length of exponential sequence: 5

    enter "a" value: 0.8

    y= 1.0000 2.2255 4.9530 11.0232 24.5325 54.5982

    enter the length of the FFT sequence: 10

    98.3324 -73.5207 -30.9223i 50.9418 +24.7831i -41.7941 -16.0579i38.8873 + 7.3387i -37.3613 38.8873 - 7.3387i -41.7941 +16.0579i50.9418 -24.7831i -73.5207 +30.9223i

    GRAPHS :

    15

  • 8/3/2019 Dsp Record

    16/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

    50

    100exponential response

    time

    amplitude

    0 1 2 3 4 5 6 7 8 90

    50

    100

    k

    |x(k)|

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

    0

    5

    k

    arg(x(k))

    INFERENCE : The FFT for impulse, step, ramp and exponential sequences is generatedusing the FFT command. The magnitude plot is the absolute value of magnitude versus the

    samples and the phase plot is the phase angle versus the samples is plotted for different

    signals for different values. This program is very simple and requires defining the signaland finding FFT and plotting.

    RESULT : The FFT of different signals like impulse, step, ramp and exponential is found

    and the magnitude and phase plots of the same is plotted.

    16

  • 8/3/2019 Dsp Record

    17/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    5. PROGRAM TO VERIFY DECIMATION AND INTERPOLATION

    AIM : To verify Decimation and Interpolation of a given Sequences

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The sampling rate alteration that is employed to generate

    a new sequence with a sampling rate higher or lower than that of a given sequence. Thus, if

    x[n] is a sequence with a sampling rate of FT Hz and it is used to generate another sequencey[n] with a desired sampling rate of FT

    ' Hz, then the sampling rate alteration ratio is given

    by FT'/ FT = R.

    If R > 1, the process is called interpolation and results in a sequence with a higher

    sampling rate. If R < 1, the sampling rate is decreased by a process called decimation and it

    results in a sequence with a lower sampling rate.

    The decimation and interpolation can be carried out by using the pre-defined commandsdecimate and interp respectively.

    PROGRAMS:

    % DECIMATION

    clc;

    clear all;

    close all;

    disp('Let us take a sinusoidal sequence which has to be decimated: ');

    fm=input('Enter the signal frequency fm: ');

    fs=input('Enter the sampling frequnecy fs: ');T=input('Enter the duration of the signal in seconds T: ');

    dt=1/fs;

    t=dt:dt:T;

    M=length(t);

    m=cos(2*pi*fm*t);

    r=input('Enter the factor by which the sampling frequency has to be

    reduced r: ');

    md=decimate(m,r);

    figure(1);

    subplot(3,1,1);

    plot(t,m);

    grid;

    xlabel('t-->');

    ylabel('Amplitude-->');

    title('Sinusoidal signal before sampling');

    subplot(3,1,2);

    stem(m);

    grid;

    xlabel('n-->');

    ylabel('Amplitudes of m -->');

    title('Sinusoidal signal after sampling before decimation');

    subplot(3,1,3);

    17

  • 8/3/2019 Dsp Record

    18/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    stem(md);

    grid;

    title('Sinusoidal after decimation');

    xlabel('n/r-->');

    ylabel('Amplitude of md-->');

    Output:Enter the signal frequency fm: 2Enter the sampling frequnecy fs: 100

    Enter the duration of the signal in seconds T: 1

    Enter the factor by which the sampling frequency has to be reduced r: 2

    GRAPHS:

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

    0

    1

    t-->

    Amplitude--> Sinusoidal signal beforesampling

    0 10 20 30 40 50 60 70 80 90 100-1

    0

    1

    n-->Amplitudesof

    m-->

    Sinusoidal signal after samplingbeforedecimation

    0 5 10 15 20 25 30 35 40 45 50-1

    0

    1Sinusoidal after decimation

    n/r-->Amplitudeofmd-->

    % INTERPOLATION

    clc;

    clear all;

    close all;

    disp('Let us take a sinusoidal sequence which has to be interpolated: ');

    fm=input('Enter the signal frequency fm: ');

    fs=input('Enetr the sampling frequnecy fs: ');

    T=input('Enter the duration of the signal in seconds T: ');

    dt=1/fs;

    t=dt:dt:T;

    M=length(t);

    m=cos(2*pi*fm*t);

    r=input('Enter the factor by which the sampling frequency has to beincreased r: ');

    md=interp(m,r);

    figure(1);

    subplot(3,1,1);

    plot(t,m);

    grid;

    xlabel('t-->');

    ylabel('Amplitude-->');

    title('Sinusoidal signal before sampling');

    18

  • 8/3/2019 Dsp Record

    19/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    subplot(3,1,2);

    stem(m);

    grid;

    xlabel('n-->');

    ylabel('Amplitudes of m -->');

    title('Sinusoidal signal after sampling before interpolation');

    subplot(3,1,3);

    stem(md);

    grid;

    title('Sinusoidal after interpolation');

    xlabel('n x r-->');

    ylabel('Amplitude of md-->');

    Outputs:Enter the signal frequency fm: 2

    Enetr the sampling frequnecy fs: 100

    Enter the duration of the signal in seconds T: 1

    Enter the factor by which the sampling frequency has to be increased r: 2

    GRAPHS:

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

    0

    1

    t-->

    Amplitude-->

    Sinusoidal signal before sampling

    0 10 20 30 40 50 60 70 80 90 100-1

    0

    1

    n-->Amplitudesofm

    -->

    Sinusoidal signal after sampling before interpolation

    0 20 40 60 80 100 120 140 160 180 200-2

    0

    2Sinusoidal after interpolation

    n x r-->Amplitudeofmd-->

    INFERENCE : The only constraint about the program is that the factors of decimation or

    interpolation should be an integers. If we want to change the sampling frequency by afactor which is not an integer it can be done by using the command resample by which we

    can change the sampling rate by a factor I / D. For this we have to interpolate by an integer

    factor I and then decimate by an integer factor D

    RESULT : The Decimation and Interpolation of given sequences is verified and graphs

    are plotted.

    19

  • 8/3/2019 Dsp Record

    20/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    6. PROGRAM TO CONVERT CD DATA INTO DVD DATA

    AIM : To convert the CD data into DVD data.

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : In this program the CD data is converted into DVD data

    by using the command resample. Here the CD data is of the sampling frequency 44.1

    kHz and the DVD data is of the sampling frequency 96.0 kHz. This is also one kind ofsampling rate conversion by a factor. In this program first we generate the CD signal and

    from that we generate the decimated version by downsampling it and upsampling results in

    DVD data in a sampled version. Then plot the CD data and DVD data signals.

    PROGRAM :

    clc;

    clear all;

    close all;fm=input('enter the signal frequency fm:');

    fs=input('enter the sampling frequency fs:');

    T=input('enter the duration of the signal in seconds:');

    dt=1/fs;

    t=0:pi/100:pi

    m=sin(2*pi*fm*t);

    subplot(411);

    plot(m);

    xlabel('time-->');

    ylabel('amplitude-->');

    subplot(412);

    stem(m);

    xlabel('time-->');ylabel('amplitude-->');

    y=resample(m,96,44);

    subplot(413)

    stem(y);

    xlabel('time-->');

    ylabel('amplitude-->');

    subplot(414)

    plot(y);

    xlabel('time-->');

    ylabel('amplitude-->');

    OUTPUTS:

    enter the signal frequency fm:2enter the sampling frequency fs:100

    enter the duration of the signal in seconds:1

    20

  • 8/3/2019 Dsp Record

    21/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPHS :

    0 20 40 60 80 100 120

    -1

    0

    1

    time-->amplitude-->

    0 20 40 60 80 100 120-1

    0

    1

    time-->amplitude-->

    0 50 100 150 200 250-2

    0

    2

    time-->amplitude-->

    0 50 100 150 200 250-2

    0

    2

    time-->amplitude-->

    INFERENCE : This program is similar to resampling of the signal by a factor of

    96000/41000. Since CD data is of the frequency 44.1 kHz and DVD data is of 96 kHz. We

    have to use the resample command only to carryout this experiment. Another way of doingthis is to Interpolate the given signal by a factor of 96000 and then decimate by 44100.

    RESULT : Hence the CD data is converted into DVD data and the graphs are plotted.

    21

  • 8/3/2019 Dsp Record

    22/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    7. GENERATION OF DUAL TONE MULTIPLE FREQUENCY (DTMF) SIGNALS

    AIM: To generation of dual tone multiple frequency ( DTMF ) signals.

    SOFTWARE REQUIRED: MAT LAB 7.0

    PROGRAM DESCRIPTION: In this program the Dual tone multiple frequency signal

    which is used in telephone systems is generated. A DTMF signal consists of a sum of two

    tones, with frequencies taken from two mutually exclusive groups of preassignedfrequencies. Each pair of such tones represents a unique number or a symbol. Decoding of

    a DTMF signal thus involves identifying the two tones in that signal and determining their

    corresponding number or symbol.

    PROGRAM:

    clc;

    clear all;

    close all;

    number=input('enter a phone number with no spaces:','s');

    fs=8192;

    T=0.5;

    x=2*pi*[697 770 852 941];

    y=2*pi*[1209 1336 1477 1602];

    t=[0:1/fs:T]';

    tx=[sin(x(1)*t),sin(x(2)*t),sin(x(3)*t),sin(x(4)*t)]/2;

    ty=[sin(y(1)*t),sin(y(2)*t),sin(y(3)*t),sin(y(4)*t)]/2;

    for k=1:length(number)

    switch number(k)

    case'1'

    tone=tx(:,1)+ty(:,1);

    sound(tone);

    plot(tone);

    case'2'

    tone=tx(:,1)+ty(:,2);

    sound(tone);

    plot(tone);

    case'3'

    tone=tx(:,1)+ty(:,3);

    sound(tone);

    plot(tone);

    case'A'

    tone=tx(:,1)+ty(:,4);

    sound(tone);

    plot(tone);

    case'4'

    tone=tx(:,2)+ty(:,1);

    sound(tone);

    22

  • 8/3/2019 Dsp Record

    23/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    plot(tone);

    case'5'

    tone=tx(:,2)+ty(:,2);

    sound(tone);

    plot(tone);

    case'6'

    tone=tx(:,2)+ty(:,3);

    sound(tone);

    plot(tone);

    case'B'

    tone=tx(:,2)+ty(:,4);

    sound(tone);

    plot(tone);

    case'7'

    tone=tx(:,3)+ty(:,1);

    sound(tone);

    plot(tone);

    case'8'

    tone=tx(:,3)+ty(:,2);

    sound(tone);

    plot(tone);case'9'

    tone=tx(:,3)+ty(:,3);

    sound(tone);

    plot(tone);

    case'C'

    tone=tx(:,3)+ty(:,4);

    sound(tone);

    plot(tone);

    case'#'

    tone=tx(:,4)+ty(:,1);

    sound(tone);

    plot(tone);

    case'0'

    tone=tx(:,4)+ty(:,2);

    sound(tone);

    plot(tone);

    case'*'

    tone=tx(:,4)+ty(:,3);

    sound(tone);

    plot(tone);

    case'D'

    tone=tx(:,4)+ty(:,4);sound(tone);

    plot(tone);

    otherwise

    disp('invalid number');

    end;

    pause(0.75);

    end;

    23

  • 8/3/2019 Dsp Record

    24/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    OUTPUT:enter a phone number with no spaces: 963

    GRAPHS:

    0 500 1000 1500 2000 2500 3000 3500 4000 4500-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 500 1000 1500 2000 2500 3000 3500 4000 4500-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 500 1000 1500 2000 2500 3000 3500 4000 4500-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    24

  • 8/3/2019 Dsp Record

    25/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    INFERENCE: In this program the two frequencies which are going to produce the dual

    tone when we press any button, that is why it is called Dual Tone Multiple Frequency

    (DTMF). The only constraint is if the number we pressed is not there in the list then it willgenerate the output as invalid number. But here the frequencies are fixed. If we want to

    generate different tone we have to change the frequencies every time.

    RESULT: Hence Dual Tone Multiple Frequency (DTMF) signals are generated and the

    output is verified.

    25

  • 8/3/2019 Dsp Record

    26/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    8. THE AUTOCORRELATION OF THE GIVEN SEQUENCE

    AIM : To find the autocorrelation of the given sequence

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : In this program, the autocorrelation of sequence x[n]

    is computed by folding the sequence with respect to real axis and then taking the

    convolution of the folded sequence with the original sequence. It is generally denoted

    by

    rxx ( l) = x(n)x(n-l) where l =..-2,-1,0,1,2,..n = -

    PROGRAM :

    clc;

    clear all;

    close all;

    a=input('Enter the first sequence: ');

    subplot(211);

    stem(a);

    grid;

    xlabel('time samples-->');

    ylabel('amplitudes-->');

    title('given sequence');

    n1=length(a);

    n2=n1-1;

    n3=n1+n2;

    b=[zeros(1,n2) a zeros(1,n2)];

    for i=1:n3

    j=n3c=[zeros(1,i-1) a zeros(1,j-i)];

    d=transpose(c);

    e(i)=b*d;

    disp('The auto correlation is: ');e

    subplot(212)

    stem(e);

    grid;

    xlabel('time samples-->');

    ylabel('amplitudes-->');

    title('The auto correlation of the given sequence');

    end;

    OUTPUTS:Enter the first sequence: [2 3 4 5]

    The auto correlation is:

    e = 10 23 38 54 38 23 10

    26

  • 8/3/2019 Dsp Record

    27/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPHS :

    1 1.5 2 2.5 3 3.5 40

    2

    4

    6

    time samples-->

    amplitudes-->

    given sequence

    1 2 3 4 5 6 70

    20

    40

    60

    time samples-->

    amplitude

    s-->

    The auto correlation of the given sequence

    INFERENCE : In this program first we have to append the zeros before and after the

    sequence which is equal to length of the sequence minus one. Then we can find the

    autocorrelation of that sequence by shifting the sequence every time by multiplying withthe same sequence. Hence it results in the autocorrelation of the sequence.

    RESULT : Hence the autocorrelation of the given sequence is calculated and plotted.

    27

  • 8/3/2019 Dsp Record

    28/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    9. POWER SPECTRAL DENSITY USING SQUARE MAGNITUDE AND

    AUTOCORRELATION

    AIM : To compute the Power Spectral Density of given signals using square magnitude

    and autocorrelation

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The stationary random processes do not have finite energyand hence do not processes a Fourier Transform. Such signals have finite average power

    and hence are characterized by a Power Density Spectrum or Power Spectral Density

    (PSD). In this program we have used the property of PSD that it can be calculated from its

    autocorrelation function by taking the time average. In the Square magnitude method aftertaking the FFT by taking the absolute value we get the PSD.

    PROGRAM :

    clc;

    clear all;

    close all;

    f1=input('Enter the frequency of first sequence in Hz: ');

    f2=input('Enter the frequency of the second sequence in Hz: ');

    fs=input('Enter the sampling frequency in Hz: ');

    t=0:1/fs:1

    x=2*sin(2*pi*f1*t)+3*sin(2*pi*f2*t)+rand(size(t));

    px1=abs(fft(x).^2)

    px2=abs(fft(xcorr(x),length(t)));

    subplot(211)plot(t*fs,10*log10(px1));%square magnitude

    grid;

    xlabel('Freq.in Hz-->');

    ylabel('Magnitude in dB-->');

    title('PSD using square magnitude method');

    subplot(212)

    plot(t*fs,10*log10(px2));%autocorrelation

    grid;

    xlabel('Freq.in Hz-->');

    ylabel('Magnitude in dB-->');

    title('PSD using auto correlation method');

    OUTPUTS:Enter the frequency of first sequence in Hz: 200

    Enter the frequency of the second sequence in Hz: 400

    Enter the sampling frequency in Hz: 1000

    28

  • 8/3/2019 Dsp Record

    29/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPHS :

    0 100 200 300 400 500 600 700 800 900 1000-50

    0

    50

    100

    Freq.in Hz-->

    MagnitudeindB

    -->

    PSD using square magnitude method

    0 100 200 300 400 500 600 700 800 900 100030

    40

    50

    60

    Freq.in Hz-->

    MagnitudeindB-->

    PSD using auto correlation method

    INFERENCE : The only constraint is to take the two frequencies must be two time lesserthan the sampling frequencies.

    RESULT : Hence the PSD is computed using the square magnitude and Autocorrealtionand graph is plotted.

    10. POWER SPECTRAL DENSITY USING PERIODOGRAM

    29

  • 8/3/2019 Dsp Record

    30/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    AIM : To compute the Power Spectral Density of given signals using Periodoram

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The stationary random processes do not have finite energyand hence do not processes a Fourier Transform. Such signals have finite average power

    and hence are characterized by a Power Density Spectrum or Power Spectral Density

    (PSD). The property of PSD that it can be calculated from its autocorrelation function bytaking the time average. In the Square magnitude method after taking the FFT by taking the

    absolute value we get the PSD. Here we used the command periodogram to estimate the

    PSD of the given signal of 200 Hz frequency.

    PROGRAM :clc;

    clear all;

    close all;

    Fs=1000;t=0:1/Fs:0.3

    x=cos(2*pi*t*200)+0.1*randn(size(t));

    periodogram(x,[ ],'twosided',512,Fs);

    GRAPHS:

    0 100 200 300 400 500 600 700 800 900-70

    -60

    -50

    -40

    -30

    -20

    -10

    Frequency (Hz)

    Power/frequency(dB/

    Hz)

    Periodogram Power Spectral Density Estimate

    INFERENCE : In the computation of the PSD here we are using the command

    periodogram so it very simple to generate the PSD of the given signal and the output is

    verified and can be compared with the other PSD generation methods.

    RESULT : Hence the PSD is computed using the periodogram and graph is plotted.

    30

  • 8/3/2019 Dsp Record

    31/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    11. POWER SPECTRAL DENSITY ESTIMATION USING PERIODOGRAM AND

    MODIFEIED PERIODOGRAM

    AIM : To compute the Power Spectral Density of given signals using Periodoram and

    Modified periodogram

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The stationary random processes do not have finite energyand hence do not processes a Fourier Transform. Such signals have finite average power

    and hence are characterized by a Power Density Spectrum or Power Spectral Density

    (PSD). The property of PSD that it can be calculated from its autocorrelation function by

    taking the time average. In the Square magnitude method after taking the FFT by taking theabsolute value we get the PSD. The same can be calculated using periododram and

    modified periodogram methods.

    PROGRAM :

    %% clearing screen

    clc;

    close all;

    clear all;

    %% psd calculation using fft

    t = 0:1023;

    x = sin(2*pi*50/1000*t)+sin(2*pi*120/1000*t);

    y = x+randn(size(t));

    N=length(y);

    f1=1000*(0:N/2-1)/N;

    p=abs(fft(y).^2)/N;

    subplot(221);

    plot(f1,10*log10(p(1:512)));

    grid;

    xlabel('frequency-->');

    ylabel('Power in dB-->');

    title(' PSD estimation using fft')

    %% psd calculation using periodogram

    [Pxx,w]=periodogram(y);

    subplot(222);

    plot(1000*w/(2*pi),10*log10(Pxx));

    grid;

    xlabel('frequency-->');

    ylabel('Power in dB-->');

    title('PSD using periodogram');

    %% psd calculation using modified periodogramw=hanning(N);

    [Pxx,w]=periodogram(y,w);

    subplot(223);

    plot(1000*w/(2*pi),10*log10(Pxx));

    grid;

    xlabel('frequency-->');

    ylabel('Power in dB-->');

    title('Modified periodogram');

    %% psd calculation using auto correlation and fft

    31

  • 8/3/2019 Dsp Record

    32/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    z=xcorr(y);

    m=length(z);

    g1=abs(fft(z));

    n2=1000*(0:(m/2)-1)/m;

    subplot(224);

    plot(n2,10*log10(g1(1:1023)));

    grid;

    xlabel('frequency-->');

    ylabel('Power in dB-->');

    title('PSD estimate by auto correlation and fft')

    GRAPHS :

    0 200 400 600-40

    -20

    0

    20

    40

    frequency-->

    PowerindB

    -->

    PSD est imation using fft

    0 200 400 600-40

    -20

    0

    20

    frequency-->

    PowerindB

    -->

    PSD using periodogram

    0 200 400 600-60

    -40

    -20

    0

    20

    frequency-->

    Powerind

    B-->

    Modified periodogram

    0 200 400 600-20

    0

    20

    40

    60

    frequency-->

    Powerind

    B-->

    PSD estimate by auto correlation and fft

    INFERENCE : In the computation of the PSD here we are using the commandperiodogram and modified periodogram is estimated by using the hanning window. So it

    very simple to generate the PSD of the given signal and the output is verified and it is

    compared with the other PSD generation methods.

    RESULT : Hence the PSD is estimated and compared with different methods.

    32

  • 8/3/2019 Dsp Record

    33/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    12. POWER SPECTRAL DENSITY ESTIMATION USING BARLETT METHOD

    AIM : To estimate the Power Spectral Density using Barlett method

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The PSD can be calculated from the autocorrelation

    function of a signal by taking its the Fourier transform, called the periodogram. In general

    the variance of the estimate Pxx ( f ) does not decay to zero as N tends to infinity. Thus

    The periodogram is not a consistent estimate of the true power density spectrumi.e., it does not converge to the true power density spectrum. Thus the estimated spectrum

    suffers from the smoothing effects and the leakage embodied in the Barlett window. Thesmoothing and leakage ultimately limit our ability to resolve closely spaced spectra. The

    methods Barlett along with Blackman Tukey and Welch are classical methods and make no

    assumption about how the data were generated and hence called nonparametric methods.

    In this method for reducing the variance in the periodogram involves three steps:1. First the N-point sequence is subdivided into K nonoverlapping segments, where

    segment has length M.2. For each segment we compute the periodogram.

    3. Finally, we average the periodograms for the K segments to obtain the Barlett

    power spectrum estimate.

    Thus Barlett methodis called as Averaging Periodograms.

    PROGRAM:

    clc;

    close all;clear all;

    t=0:1023

    x=sin(2*pi*50/1000*t)+sin(2*pi*120/1000*t);

    y=x+randn(size(t));

    N=length(y);

    k=4;

    M=N/k;

    x1=y(1:M);

    x2=y(M+1:2*M);

    x3=y(2*M+1:3*M);

    x4=y(3*M+1:4*M);

    px41=(1/M)*((abs(fft(x1))).^2);

    px42=(1/M)*((abs(fft(x2))).^2);px43=(1/M)*((abs(fft(x3))).^2);

    px44=(1/M)*((abs(fft(x4))).^2);

    px5=(px41+px42+px43+px44)/k;

    n1=1000*(0:M/2)/M;

    plot(n1,px5(1:M/2+1));

    grid;

    xlabel('Normalized frequency in Hz -->');

    ylabel('-->Power Spectrum in dB');

    title('PSD ESTIMATION USING BARLETT METHOD');

    33

  • 8/3/2019 Dsp Record

    34/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPH:

    0 50 100 150 200 250 300 350 400 450 5000

    10

    20

    30

    40

    50

    60

    Normalized frequency in Hz -->

    -->PowerSpectrumi

    ndB

    PSD ESTIMATION USING BARLETT METHOD

    INFERENCE : Estimation of Power Spectral Density using Barlett method is observed

    from the graph.

    RESULT : Hence the PSD is estimated using Barlett method.

    34

  • 8/3/2019 Dsp Record

    35/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    13. POWER SPECTRAL DENSITY ESTIMATION USING WELCH METHOD

    AIM : To estimate the Power Spectral Density using Welch method

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The PSD can be calculated from the autocorrelation

    function of a signal by taking its the Fourier transform, called the periodogram. In general

    the variance of the estimate Pxx ( f ) does not decay to zero as N tends to infinity. Thus

    The periodogram is not a consistent estimate of the true power density spectrumi.e., it does not converge to the true power density spectrum. Thus the estimated spectrum

    suffers from the smoothing effects and the leakage embodied in the Barlett window. Thesmoothing and leakage ultimately limit our ability to resolve closely spaced spectra. The

    methods Barlett along with Blackman Tukey and Welch are classical methods and make no

    assumption about how the data were generated and hence called nonparametric methods.

    Welch made two modifications to the Barlett method.1. First, he allowed the data sequence to overlap.

    2. The second modification made by Welch to the Barlett method is to window thedata segments prior to computing the periogram.

    Thus Welch methodis called asModified Periodogram.

    PROGRAM:

    clc;

    close all;

    clear all;

    fs=1024;

    f1=200;

    f2=400;

    M=128;

    t=0:1/fs:1;

    x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+rand(size(t));

    L=length(x);

    K=L/M;

    wi=hann(M+1);

    m=0;

    su=[];

    for i=1:M/2:L-M+1

    y=wi'.*x(i:M+i);

    w2=abs(fft(y).^2);su=[su;w2];

    end;

    su1=sum(su);

    su2=sum(wi.^2);

    w1=su1/su2;

    w12=10*log(w1);

    fs1=(fs/K)+2;

    t1=((1:fs1)/fs1);

    35

  • 8/3/2019 Dsp Record

    36/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    plot(t1,w12);

    grid;

    xlabel('Normalized frequency -->');

    ylabel('-->Power Spectrum in dB');

    title('Welch method of Power Spectrum Estimation');

    GRAPH:

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

    0

    10

    20

    30

    40

    50

    60

    Normalized frequency -->

    -->PowerSpectrumi

    ndB

    Welch method of Power Spectrum Estimation

    INFERENCE : Estimation of Power Spectral Density using Welch method is observedfrom the graph.

    RESULT : Hence the PSD is estimated using Welch method.

    36

  • 8/3/2019 Dsp Record

    37/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    14. PSD ESTIMATION USING BLACKMAN AND TUKEY METHOD

    AIM : To estimate the Power Spectral Density using Blackman and Tukey method.

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The PSD can be calculated from the autocorrelation

    function of a signal by taking its the Fourier transform, called the periodogram. In general

    the variance of the estimate Pxx ( f ) does not decay to zero as N tends to infinity. Thus

    The periodogram is not a consistent estimate of the true power density spectrumi.e., it does not converge to the true power density spectrum. Thus the estimated spectrum

    suffers from the smoothing effects and the leakage embodied in the Barlett window. Thesmoothing and leakage ultimately limit our ability to resolve closely spaced spectra. The

    methods Barlett along with Blackman Tukey and Welch are classical methods and make no

    assumption about how the data were generated and hence called nonparametric methods.

    Blackman and Tukey proposed and analyzed the method in which the sampleautocorrelation sequence is windowed first and then Fourier transformed to yield the

    estimate of the power spectrum.

    PROGRAM:

    clc;

    close all;

    clear all;

    fs=1024;

    f1=200;

    f2=400;

    t=0:1/fs:1;

    x=sin(2*pi*f1*t)+sin(2*pi*f2*t)+rand(size(t));

    L=length(x);

    y=xcorr(x);

    wi=hann(length(y));

    y1=wi'.*y;

    i=length(y);

    b=abs(fft(xcorr(y1)))/L;

    i1=length(b);

    t1=(1:i1)/i1;

    b1=10*log(b);

    plot(t1,b1);

    grid;

    xlabel('Normalized frequency -->');ylabel('-->Power Spectrum in dB');

    title('Blackman and Tukey method of Power Spectrum Estimation');

    37

  • 8/3/2019 Dsp Record

    38/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPH:

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

    0

    50

    100

    150

    200

    Normalized frequency -->

    -->P

    owerSpectrumi

    ndB

    Blackman and Tukey method of Power Spectrum Estimation

    INFERENCE : Estimation of Power Spectral Density using Blackman and Tukey method

    is observed from the graph.

    RESULT : Hence the PSD is estimated using Blackman and Tukey method.

    38

  • 8/3/2019 Dsp Record

    39/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    15. POWER SPECTRUM ESTIMATION USING YULE-WALKER METHOD

    AIM : To estimate the Power Spectral Density using Yule-Walker method.

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The Power Spectral Density can be calculated by Barlett

    along with Blackman Tukey and Welch are the classical methods and make no assumption

    about how the data were generated and hence called nonparametric methods. Thenonparametric power spectrum estimation methods require the availability of long data

    records in order to obtain the necessary frequency resolution required in many applications.

    The limitations of nonparametric methods:1. The inherent assumption that the auto correlation estimate is zero for m >= N.

    2. Another inherent assumption is that in the periodogram estimate the data are

    periodic with period N.

    Neither one of these assumptions is realistic.

    The modeling approach eliminates the need for window functions and the assumption thatthe auto correlation is zero for |m| >= N. As a consequence, Parametric ( model-based )power spectrum estimation methods avoid the problem of leakage and provide better

    resolution than do the FFT based, nonparametric methods. The Yule-Walker and Burg

    methods are calledParametric methods of Power Spectrum Estimation.

    Yule-Walker method: The Yule-walker method estimates simply the auto correlation

    from the data and use the estimates to solve for the AR model parameters.The result is astable AR model.

    PROGRAM:

    clc;

    close all;

    clear all;

    a=[1 -2.2137 2.9408 -2.1697 0.9609]; % AR filter coefficients

    randn('state',1);

    x=filter(1,a,randn(256,1)); % AR system output

    pyulear(x,4); % Fourth-order estimate

    xlabel('Normalized frequency -->');

    ylabel('-->Power Spectrum in dB');

    title('Yule-Walker method of Power Spectrum Estimation');

    39

  • 8/3/2019 Dsp Record

    40/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    GRAPH:

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

    -20

    -10

    0

    10

    20

    30

    Normalized frequency -->

    -->P

    owerSpectrumi

    ndB

    Yule-Walker method of Power Spectrum Estimation

    INFERENCE : Estimation of Power Spectral Density using Yule-Walker method is

    observed from the graph.

    RESULT : Hence the PSD is estimated using Yule-Walker method.

    16. POWER SPECTRUM ESTIMATION USING BURG METHOD

    40

  • 8/3/2019 Dsp Record

    41/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

    AIM : To estimate the Power Spectral Density using Burg method.

    SOFTWARE REQUIRED : MAT LAB 7.0

    PROGRAM DESCRIPTION : The Power Spectral Density can be calculated by Barlettalong with Blackman Tukey and Welch are the classical methods and make no assumption

    about how the data were generated and hence called nonparametric methods. The

    nonparametric power spectrum estimation methods require the availability of long datarecords in order to obtain the necessary frequency resolution required in many applications.

    The limitations of nonparametric methods:

    1. The inherent assumption that the auto correlation estimate is zero for m >= N.2. Another inherent assumption is that in the periodogram estimate the data are

    periodic with period N.

    Neither one of these assumptions is realistic.

    The modeling approach eliminates the need for window functions and the assumption that

    the auto correlation is zero for |m| >= N. As a consequence, Parametric ( model-based )power spectrum estimation methods avoid the problem of leakage and provide better

    resolution than do the FFT based, nonparametric methods. The Yule-Walker and Burgmethods are calledParametric methods of Power Spectrum Estimation.

    Burg method: The method devised by Burg for estimating the AR parameters can be

    viewed as an order recursive least squares lattice method, based on the minimization of the

    forward and backward errors in linear predictors, with the constraint that the ARparameters satisfy the Levinson-Durbin recursion.

    PROGRAM:

    clc;

    close all;

    clear all;

    a=[1 -2.2137 2.9408 -2.1697 0.9609]; % AR filter coefficients

    randn('state',1);

    x=filter(1,a,randn(256,1)); % AR system output

    pburg(x,4); % Fourth-order estimate

    xlabel('Normalized frequency -->');

    ylabel('-->Power Spectrum in dB');

    title('Burg method of Power Spectrum Estimation');

    GRAPH:

    41

  • 8/3/2019 Dsp Record

    42/42

    SIGNAL PROCESSING LAB M Tech (PTPG), SSP, I SEM

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

    -20

    -10

    0

    10

    20

    30

    Normalized frequency -->

    -->PowerSpectrumi

    ndB

    Burg method of Power Spectrum Estimation

    INFERENCE : Estimation of Power Spectral Density using Burg method is observed from

    the graph.

    RESULT : Hence the PSD is estimated using Burg method.