ac mat lab prog

Upload: chandujonty

Post on 04-Apr-2018

238 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 AC MAT LAB PROG

    1/40

    INTRODUCTION TO MATLAB.

    1. GENERATION OF BASIC SIGNALS USING MATLAB

    AIM : To generate basic signals like

    unit impulse, unit step, unit ramp

    signal and Exponential signals.

    Requirements : Computer with

    MATLAB software

    % (a). Program for the generation of

    UNIT impulse signal

    clc; close all; clear all;f=-2:1:2;

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

    figure(1)

    subplot(2,2,1);

    stem(f,y);

    title('unit impulse');

  • 7/29/2019 AC MAT LAB PROG

    2/40

    % (b). Program for the generation of

    UNIT step signal

    n=input('enter the n value');

    f=0:1:n-1;

    y=ones(1,n);

    figure(1)

    subplot(2,2,2);

    stem(f,y);

    title('unit step');

    % (c).Program for the generation ofunit RAMP signal

  • 7/29/2019 AC MAT LAB PROG

    3/40

    n=input('enter the n value');

    f=0:n;

    y=0:n;figure(1)

    subplot(2,2,3);

    stem(f,f);

    title('unit ramp');

    % (d).Program for the generation of

    Exponential signal

    n=input('the length of i/p sequency');

    f=0:n

    a=input('enter the a value');y=exp(a*f);

    figure(1)

  • 7/29/2019 AC MAT LAB PROG

    4/40

    subplot(2,2,4);

    stem(f,y);

    title('unit exponential')

    OUTPUT:

    y = 0 0 1 0 0

    Enter the n value 6

    Enter the n value 7

    The length of i/p value 5

    f = 0 1 2 3 4 5 6

    Enter the a value 2

  • 7/29/2019 AC MAT LAB PROG

    5/40

    FIG: Basic signals like unit impulse,

    unit step, unit ramp signal and

    Exponential signals

    Result: Hence we generate basicsignals like unit impulse, unit step,

    unit ramp signal and Exponential

    signals.

    -2 -1 0 1 20

    0.2

    0.4

    0.6

    0.8

    1unit impulse

    0 2 4 60

    0.2

    0.4

    0.6

    0.8

    1unit step

    0 2 4 60

    2

    4

    6

    unit ramp

    0 2 4 60

    1

    2

    3

    4

    x-axis

    y-axis

    unit exponential

  • 7/29/2019 AC MAT LAB PROG

    6/40

    2. AMPLITUDE MODULATION &

    DEMODULATION

    AIM: To generate the amplitude

    modulated signal and also calculate

    the modulation index

    Requirements : Computer with

    MATLAB software.

    Program: for the generation of

    amplitude modulated signal.

    %amplitude modulation

    clc;

    clear all;

    close all;

    f=500;

    fc=5000;

  • 7/29/2019 AC MAT LAB PROG

    7/40

    fs=8*fc;

    ts=1/fs;

    t=0:ts:8/f;m=cos(2*pi*f*t);

    c=cos(2*pi*fc*t);

    s=c+m.*c;

    s1=s.*c;

    subplot(4,1,1);

    plot(t,m);

    xlabel('time');

    ylabel('magnitude');

    title('message signal');

    subplot(4,1,2);

    plot(t,c);

    xlabel('time');

  • 7/29/2019 AC MAT LAB PROG

    8/40

    ylabel('magnitude');

    title('carrier signal');

    subplot(4,1,3);plot(t,s);

    xlabel('time');

    ylabel('magnitude');

    title('Amplitude modulated signal');

    d=s.*c;

    subplot(4,1,4);

    plot(t,d);

    xlabel('time');

    ylabel('magnitude');

    title('demoduated signal')

  • 7/29/2019 AC MAT LAB PROG

    9/40

    Fig: Amplitude Modulation

    Result: Hence we generate the

    amplitude modulated signal and

    acalculated the modulation index

  • 7/29/2019 AC MAT LAB PROG

    10/40

    3. SINGLE SIDEBAND SYSTEM

    AIM: To study the generation ofsingle side band (SSB) amplitudemodulation and de- modulation.

    Requirements : Computer with

    MATLAB software.

    Program:

    %single side band system

    clc;clear all;

    close all;

    Ac=1;

    f=500;

    fc=5000;

    fs=8*fc;

  • 7/29/2019 AC MAT LAB PROG

    11/40

    ts=1/fs;

    t=0:ts:8/f;

    m=cos(2*pi*f*t);c=cos(2*pi*fc*t);

    s1=Ac/2*(m.*c-

    hilbert(m).*sin(2*pi*fc*t));

    s2=Ac/2*(m.*c+hilbert(m).*sin(2*pi*fc

    *t));

    subplot(5,1,1);

    plot(t,m);

    xlabel('time');

    ylabel('magnitude');

    title('message signal');subplot(5,1,2);

    plot(t,c);

  • 7/29/2019 AC MAT LAB PROG

    12/40

    xlabel('time');

    ylabel('magnitude');

    title('carrier signal');subplot(5,1,3);

    plot(t,s1);

    xlabel('time');

    ylabel('magnitude');

    title('SSB with Upper sideband

    signal');

    d=s1.*c;

    subplot(5,1,4);

    plot(t,s2);

    xlabel('time');ylabel('magnitude');

  • 7/29/2019 AC MAT LAB PROG

    13/40

    title('SSB with lowerside band

    signal');

    subplot(5,1,5);

    plot(t,d);

    xlabel('time');

    ylabel('magnitude');

    title('demodulated signal');

  • 7/29/2019 AC MAT LAB PROG

    14/40

    Fig: SSB SYSTEM

    Result: Hence we generated singleside band (SSB) amplitudemodulation and de- modulation.

  • 7/29/2019 AC MAT LAB PROG

    15/40

  • 7/29/2019 AC MAT LAB PROG

    16/40

    4.DOUBLE SIDE BAND SYSTEM

    AIM: To obtain the outputcharacteristics of a Double side

    band- Suppressed carrier AM

    modulation and demodulation

    Requirements : Computer withMATLAB software.

    Program:

    %double side band suppressed

    carrier

    clc;

    clear all;

    close all;

    f=500;

    fc=5000;

  • 7/29/2019 AC MAT LAB PROG

    17/40

    fs=8*fc;

    ts=1/fs;

    t=0:ts:8/f;m=cos(2*pi*f*t);

    c=cos(2*pi*fc*t);

    s=m.*c;

    subplot(4,1,1);

    plot(t,m);

    xlabel('time');

    ylabel('magnitude');

    title('message signal');

    subplot(4,1,2);

    plot(t,c);

    xlabel('time');

    ylabel('magnitude');

  • 7/29/2019 AC MAT LAB PROG

    18/40

    title('carrier signal');

    subplot(4,1,3);

    plot(t,s);xlabel('time');

    ylabel('magnitude');

    title('DSBSC signal');

    d=s.*c;

    subplot(4,1,4);

    plot(t,d);

    xlabel('time');

    ylabel('magnitude');

    title('demodulated signal');

  • 7/29/2019 AC MAT LAB PROG

    19/40

    Fig: DSB SYSTEM

  • 7/29/2019 AC MAT LAB PROG

    20/40

    Result: Hence we obtained the

    output characteristics of a Double

    side band- Suppressed carrier AM

    modulation and demodulation

  • 7/29/2019 AC MAT LAB PROG

    21/40

    5.FREQUENCY MODULATION

    Aim: To generate a frequencymodulation and demodulation signal

    using Matlab Source.

    Requirements : Computer with

    MATLAB software

    Program:

    %frequency mopdulation

    clc;clear all;

    close all;

    ac=5;

    f=500;

    fc=5000;

    fs=8*fc;

  • 7/29/2019 AC MAT LAB PROG

    22/40

    ts=1/fs;

    t=0:ts:8/f;

    m=cos(2*pi*f*t);c=cos(2*pi*fc*t);

    s=ac*cos(2*pi*fc*t+5*sin(2*pi*f*t));

    subplot(3,1,1);

    plot(t,m);

    xlabel('time');

    ylabel('magnitude');

    title('message signal');

    subplot(3,1,2);

    plot(t,c);

    xlabel('time');

    ylabel('magnitude');

    title('carrier signal');

  • 7/29/2019 AC MAT LAB PROG

    23/40

    subplot(3,1,3);

    plot(t,s);

    xlabel('time');ylabel('magnitude');

    title('FM signal');

    Fig: FREQUENCY MODULATION &DE MODULATION

    Result: Hence we generate a

    frequency modulation and

  • 7/29/2019 AC MAT LAB PROG

    24/40

    demodulation signal using Matlab

    Source.

  • 7/29/2019 AC MAT LAB PROG

    25/40

    6. PULSE WIDTH MODULATION

    AIM: To construct pulse widthmodulation circuit and observe

    modulation and demodulation.

    Requirements : Computer with

    MATLAB software.

    Program:

    %pulse width modulation

    clc;clear all;

    close all;

    fc=1000;

    fs=4*fc;

    ts=1/fs;

    f=200;

  • 7/29/2019 AC MAT LAB PROG

    26/40

    t=0:ts:5/f;

    x=.4*sin(2*pi*f*t)+.5;

    s=modulate(x,fc,fs,'pwm');subplot(3,1,1);

    plot(x);

    subplot(3,1,2);

    plot(s);

    d=demod(s,fc,fs,'pwm');

    subplot(3,1,3);

    plot(d);

  • 7/29/2019 AC MAT LAB PROG

    27/40

    Fig: PULSE WIDTH

    MODULATION

  • 7/29/2019 AC MAT LAB PROG

    28/40

    Result: Hence we constructed pulse

    width modulation circuit and

    observed modulation and

    demodulation.

  • 7/29/2019 AC MAT LAB PROG

    29/40

    7. PULSE AMPLITUDE

    MODUATION

    AIM: To generate a Pulse amplitude

    modulated signal and also

    demodulate the original signal.

    Requirements : Computer with

    MATLAB software.

    Program:

    %pulse amplitude modulation

    clc;

    clear all;

    close all;

    f=500;

    fs=12*f;

  • 7/29/2019 AC MAT LAB PROG

    30/40

    ts=1/fs;

    t=0:ts:5/f;

    x=0.4*cos(2*pi*f*t)+.5;c=square(2*pi*f*t,0.5);

    subplot(2,1,1);

    plot(x);

    subplot(2,1,2);

    s=x.*c;

    stem(abs(s));

  • 7/29/2019 AC MAT LAB PROG

    31/40

    Fig: Pulse Amplitude

    Modulation

    Result: Hence we generate a Pulseamplitude modulated signal and also

    demodulate the original signal.

  • 7/29/2019 AC MAT LAB PROG

    32/40

    8. PULSE POSITION MODULATION

  • 7/29/2019 AC MAT LAB PROG

    33/40

    AIM: To generate a Pulse position

    modulated/demodulated signal using

    Matlab source

    Requirements : Computer with

    MATLAB software.

    Program:

    %pulse position mosulation

    clc;

    clear all;

    close all;fc=1000;

    fs=4*fc;

    ts=1/fs;

    f=200;

    t=0:ts:5/f;

    x=.4*sin(2*pi*f*t)+.5;

  • 7/29/2019 AC MAT LAB PROG

    34/40

    s=modulate(x,fc,fs,'ppm',0.6);

    subplot(3,1,1);

    plot(x);subplot(3,1,2);

    plot(s);

    d=demod(s,fc,fs,'ppm',0.6);

    subplot(3,1,3);

    plot(d);

  • 7/29/2019 AC MAT LAB PROG

    35/40

    Fig: PULSE POSITION

    MODUALTION

  • 7/29/2019 AC MAT LAB PROG

    36/40

    Result: Hence we generated a Pulse

    position modulated/demodulated

    signal using Matlab source.

  • 7/29/2019 AC MAT LAB PROG

    37/40

    9. SAMPLING THEOREM

    AIM: To sample the given inputsignal at different sampling rates and

    reconstruct the original signal by

    passing through a low pass filter.

    Requirements : Computer withMATLAB software.

    Program:

    % sampling theorem

    clc;

    clear all;

    close all;

    fm=100;

    fs=600;

    ts=1/fs;

  • 7/29/2019 AC MAT LAB PROG

    38/40

    t=0:ts:10/fm;

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

    subplot(4,1,1);stem(x);

    fx=fft(x);

    xr=ifft(fx);

    subplot(4,1,2);

    stem(xr);

    fm2=400;

    x2=sin(2*pi*fm2*t);

    subplot(4,1,3);

    stem(t,x2);

    fx1=fft(x2);

    xr1=ifft(fx1);

    subplot(4,1,4);

  • 7/29/2019 AC MAT LAB PROG

    39/40

    stem(xr1);

  • 7/29/2019 AC MAT LAB PROG

    40/40

    Fig: SAMPLING THEOREM

    RESULT: Hence sampling theorem is verified.